0
Need help with regex pattern
I'm looking for a pattern that matches a string like this: string = "1. Solo 2,000, 000.2. Learner30,000.3.solearn3000." I'm trying to extract all the money values in the string i.e 2,000,000, 30,000, 3000 so i can sum the later. Mypattern = pattern = r"^[1-9][,0]+" re.findall(Mypattern, string) always comes back empty
4 Answers
+ 2
â©âźâ
âźâ© I got it Thanks to you. I changed it to:
r"[\d,]{5,30}"
+ 1
pattern = r"[1-9][\,?0+]+"
0
â©âźâ
âźâ© Thanks man. The problem here is the numbers 1. , 2. which represents the index of the names are also found by your pattern
0
135. Solo 300,000
136. learners 300,000
137. North Korea 150,000
138. Famile 1,500,000.
This is an example of what the string looks like plus some other messy stuff. I want the extract the money part and dump the rest including the index (137,138 etc).