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

15th Jul 2021, 9:54 PM
Nwalozie Elijah
Nwalozie Elijah - avatar
4 ответов
+ 2
✩✮★✮✩ I got it Thanks to you. I changed it to: r"[\d,]{5,30}"
15th Jul 2021, 10:43 PM
Nwalozie Elijah
Nwalozie Elijah - avatar
+ 1
pattern = r"[1-9][\,?0+]+"
15th Jul 2021, 10:49 PM
blackfish
blackfish - avatar
0
✩✮★✮✩ Thanks man. The problem here is the numbers 1. , 2. which represents the index of the names are also found by your pattern
15th Jul 2021, 10:32 PM
Nwalozie Elijah
Nwalozie Elijah - avatar
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).
15th Jul 2021, 10:40 PM
Nwalozie Elijah
Nwalozie Elijah - avatar