Regular Expressions :
It matches a pattern string, the string for processing, can greatly reduce the amount of code strings of complex processing
Character group : it is a variety of characters in the same position possible to form a group of characters, with [] indicate, but it can only be the result of a number or an uppercase or lowercase letters, etc.
The following test at the site, for example http://tool.chinaz.com/regex/
# Regular expression matching string matching result # [0-9] 99 [0-9] is equivalent with the wording [0123456789] # [0123456789] 00 # match only lowercase characters [az] 1 None where az not match numbers # [AZ] ZZ # [AZ] AA here only uppercase character string matching # [a-C-Z0-5a] A6b a, where b is the range of numbers to be matched so did 6 0-5
Yuan characters:
1. '' matches any character other than a newline
# Regular expression matching string matches # . AA # .. 1. 1 # . & & # . Newline None
2. '\ W' matches the letter or underscore or digital --word
It is equivalent to [A-Z0-9a-z_]
# Regular expression matching string matching result # \ WAA # \ W. 1. 1 # \ W & None # \ W newline None # \ W _ _
3. '\ S' matches any whitespace --space
If you do not write anything matching the string will be matched to a result where whitespace spaces, tab key, enter a blank character, etc.
4. '\ D' matches any number --digit
Equivalent to [0-9]
# Regular expression matching string matching result # \ DA None # \. 1. 1 D # \ D & None
5. '\ W' matching non-alphabetic or numeric underscore
Results and '\ w' of the opposite, and a blank character may be matched, If [\ w \ W] is equivalent to the effect of the global match; equivalent to [^ A-Z0-9a-z_]
6. '\ D' non-matching character
Results and '\ d' opposite, and a blank character may match; equivalent to [^ 0-9]
7. '\ S' match non-whitespace characters
Results and '\ s' contrast, in addition to other empty string match
8. '\ N' matches a newline
9. '\ T' matches a tab (tab)
10. '\ B' matches the end of a word
# Regular expression matching string matches # . \ B abx the X-match one character and returns it to the end of the character # b \ b ABB b matches a string if it is the end of it returns b # b \ b aaa None
11. '\ F' match for a website page
12. '\ R' match a carriage
13. '\ V' matches a vertical tab
14. '\ B' matches a non-word boundary
# Regular expression matching string matching result # V \ V B Vers # VE \ Vers VE B # S \ B Vers None
15. '\ Num' matches a positive integer
# Regular expression matching string matching results # (.) \ 11 122 11, 22 matches in a row adjacent two characters
16. '^' Matches the beginning of the string
Equivalent startswith ()
# Regular expression matching string matching result # ^ [AZ] A A456A
17. End '$' matching string
Equivalent endswith ()
# Regular expression matching string matching results # [AZ] $ ASD D
18.....