Finding numbers after a certain keyword using Python -


i have form (a string) want process. form can contain occurrences of this, example: >>1244.

i need grab every number after every occurrence of >>, i'm not sure how. i'm thinking regex, i'm terrible @ it. i've read several similar questions, answers wildly different, don't apply (they find next word after keyword) or use contradicting approaches.

what's best way this? thanks.

you can use findall() positive behind:

>>> import re >>> >>> s = ">>1244" >>> re.findall(r"(?<=>>)\d+", s) ['1244'] >>> >>> s = ">>1244 >>500" >>> re.findall(r"(?<=>>)\d+", s) ['1244', '500'] 

here (?<=>>)\d+ expression match 1 or more digits (\d+) go after >>.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -