Regular expressions learning

Re Import 

Line = 'booooooobrucebbbaaaacaby123'
# regex_str = '^ B. * 3 $' # at the beginning of any string B ^ (what to write back to the beginning of what is to start with what symbol). (any character) * (repeat unlimited) $ (to sign before the end of what is what is to what end)
# regex_str = '. *? (b. *? b). *' # regular match time default greedy mode? (Canceled greedy)
# regex_str = '. * (B. + B). *' # + (Represented at least once occurs, the example means any character between b and b at least once)
# = regex_str '. . * (. b {2,5} b) * '# {2} ( braces frequency value represents occurring) {2} (example meaning: appears at least twice) {2, 5} example means occurs at least 2 times, 5 times the most frequent
# regex_str = | # | (example meaning: match to bruce or Bobby) '* (bruce Bobby) *..'
regex_str = '([ABCD] OOO)' # | (example meaning: abcd back to the beginning of the string along the ooo)

match_obj = re.match (regex_str, Line)
IF match_obj:
Print (match_obj.groups (. 1))

Guess you like

Origin www.cnblogs.com/brucexl/p/11432738.html