python re in. * A Notes

a module for re python regular expression matching. * to match zero or more characters. But it is a greedy pattern matching, matching characters will comply with the rules as much as possible to see an example of the following scenarios:.
The Data = "dut_rate IS 36.1001, ref_rate IS 3778.543"
match_obj = re.search (r "dut_rate * IS \. .. + S (\ + D) (\ + D) * ref_rate. IS. (\ + D) (\ + D) ", Data, re.M |. re.I)

Matching result in group (1) is 36, Group (2): 1001, Group (3): 8, Group (. 4):. 543
. 3 can be seen from the greedy * effect, causing the output 8 instead of 3778

Published 22 original articles · won praise 3 · Views 757

Guess you like

Origin blog.csdn.net/weixin_39662684/article/details/104900014