The reptile has been a regular self-cultivation!

In the re module

import re

* Search to find the first match

 

* Findall find all matches

 

 * Backslash followed by numerals 1 to 99 are enclosed in parentheses front left to right sequence number, the first bracket is a small, up to 99

  Such as: (Fishc) \ 1 do not match and the match Fishc FishcFishc, (F) (S) \ 1 \ 2 >> matching is FSFS \ 1 refers to F \ 2 refers to the S

* [...] meta-characters lose themselves inside the action, may become another role, such as [.] Match is simple. And outside \. However, the same effect [\] is wrong \ still represents the character translation, Representative [^ abc] in addition to matching abc, and [abc ^] Representative fear of a match abc ^ wherein

 

Regular expressions are enabled by default greedy mode:

  as follows

How to open a non-greedy mode: After adding a question mark represents a repeating metacharacters, ie open non-greedy mode

 

No. This is very important !!, two above text has described the picture

\ B letters and _ are not considered a word boundary, and the other symbol is also considered a word boundary!

Only part of the picture ....

   

 

 

 

 P60 end of the regular expression compiler flags        

 

 

 

 findall () if you are content with sub-group, sub-group match he will return back to the match, if multiple sub-group, it will return in the form of tuple

 

 

 (? It is the beginning of the regular expression syntax extensions

(:? .. ​​so that does not return as a sub-group findall

 

Guess you like

Origin www.cnblogs.com/ningxinjie/p/10965842.html