I would like to remove every second occurence of a comma in my string but starting from the second comma.
My string: "30, 20, 40, 50"
and I would like my result to be: "30 20, 40 50"
So far I have been using regular expressions to try and achieve this by the following reg sub: myString = re.sub('(,[^,])*,', r'\1', myString) but this results in: "30, 20 40, 50".
I hope someone can help me out here.
-
I got "30 20 40 50" for this expression and not "30, 20 40, 50" on my machine.Jérôme Richard– Jérôme Richard2021-04-13 08:10:09 +00:00Commented Apr 13, 2021 at 8:10
-
Please stop editing the thread with mistakes. Leave it as is and move on, thank you.user15227672– user152276722021-04-14 13:17:54 +00:00Commented Apr 14, 2021 at 13:17
Add a comment
|