#重复匹配:. [] ? * + {}
?: The left character appears 0 or 1 times
Print (Re.findall (' ab ', ' a ab ABB abbb abbbbbb '))
Print (Re.findall (' ab{0,1} ', ' A ab ABB abbb abbbbbb '))
*: The character on the left appears 0 or infinite times
Print (Re.findall (' ab* ', ' a ab ABB abbb abbbbbb abbc123bbbb '))
Print (Re.findall (' ab{0,} ', ' A ab ABB abbb abbbbbb abbc123bbbb '))
+: The character on the left appears 1 or infinite times
Re.findall (' ab+ ', ' a ab ABB abbb abbbbbb abbc123bbbb ')
Re.findall (' Ab{1,} ', ' A ab ABB abbb abbbbbb abbc123bbbb ')
Greedy match:. *
Print (Re.findall (' a.*b ', ' a123b456b '))
Non-greedy match:. *?
Print (Re.findall (' a.*?b ', ' a123b456b '))
Group: ()
Print (Re.findall (' <imag href=\ "(. *) \"/> ",
' ' 
Attention:
The use of regular expressions in Python is first recognized by Python. (That is, it will consume one time first \)
Print (Re.findall (' a\\\\c ', ' a\c A12 a2c ')) # ' a\\c ' so you want to write two more
Print (Re.findall (R ' a\\c ', ' a\c A12 a2c ')) # ' a\\c '
1 #Why the same expression search and findall have different results:2 Print(Re.search ('\ (([\+\-\*\/]*\d+\.? \d*) +\)',"1-12* (60+ ( -40.35/5)-( -4*3))"). Group ())#( -40.35/5)3 Print(Re.findall ('\ (([\+\-\*\/]*\d+\.? \d*) +\)',"1-12* (60+ ( -40.35/5)-( -4*3))"))#['/5 ', ' * * ']4 5 #See this example: (\d) + equivalent (\d) (\d) (\d) (\d) ..., a series of groupings6 Print(Re.search ('(\d) +','123'). Group ())#The role of group is to bring all the groups together to show7 Print(Re.findall ('(\d) +','123'))#FindAll result is a result of the group and is the result of the last group8 3 values were taken for this case9' 1 ' 2 ' 3, respectively.'TenAnd then it shows the number 3.
Python Learning Journey ——— re-module regular expressions