Tag: expression returns the specified any regular module digital print class
Re module \ Regular expression one, meta-character
1,. ^ $ * + ? { } [ ] | ( ) \
"." Represents (any one character) "*" for (any number of arbitrary characters, 0-Infinity) "+" stands for (any one or no number, 1-infinity) "?" Represents (0 or 1 characters) "^" for (beginning of String) "$" for (end of String) "{}" representation (specified number of times)
2. Escape character \
1), backslash followed by meta-character removal of special functions, such as \.
2), back slash behind with ordinary characters to achieve special functions, such as \d
\d matches any decimal number; it is equivalent to class [0-9]. \d matches any non-numeric character; it is equivalent to class [^0-9]. \s matches any whitespace character; it is equivalent to class [\t\n\r\f\v]. \s matches any non-whitespace character; it is equivalent to class [^ \t\n\r\f\v]. \w matches any alphanumeric character; it is equivalent to class [a-za-z0-9_]. \w matches any non-alphanumeric character; it is equivalent to a class [^a-za-z0-9_]\b matches a special character boundary, such as a space, &,#, etc.
3. Group ()
ret = Re.findall ("(yuan) +", "Lalal11yuanhao22yuanyuanhaohao33yuan") #分组 (), returned with the FindAll command is a grouped content print (ret) #[' yuan ', ' Yuan ', ' yuan ']
Day of the Python regular expression