python - regex match last occurence -
I'm trying to find ways other than these two:
# this In case \ d +, match the last 24242 & gt; & Gt; & Gt; Test = "123_4242_24242lj.:" & Gt; & Gt; & Gt; Obj = re.search (r "\ d + (?!. * \ D)", test) & gt; & Gt; & Gt; Obj.group () '24242' & gt; & Gt; & Gt; Re.findall (r "\ d +", test) [- 1] '24242' Any ideas?
This lookahead based regex matches the previous issue in a single digit:
\ D + (? = \ D * $)
Comments
Post a Comment