Python Regex replace

前端 未结 6 1385
野性不改
野性不改 2021-02-05 05:01

Hey I\'m trying to figure out a regular expression to do the following.

Here is my string

Place,08/09/2010,\"15,531\",\"2,909\",650

I

6条回答
  •  萌比男神i
    2021-02-05 05:27

    If you need a regex solution, this should do:

    r"(\d+),(?=\d\d\d)"
    

    then replace with:

    "\1"
    

    It will replace any comma-delimited numbers anywhere in your string with their number-only equivalent, thus turning this:

    Place,08/09/2010,"15,531","548,122,909",650

    into this:

    Place,08/09/2010,"15531","548122909",650

    I'm sure there are a few holes to be found and places you don't want this done, and that's why you should use a parser!

    Good luck!

提交回复
热议问题