Python Regex replace

前端 未结 6 1314
野性不改
野性不改 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条回答
  •  借酒劲吻你
    2021-02-05 05:31

    Another way of doing it using regex directly:

    >>> import re
    >>> data = "Place,08/09/2010,\"15,531\",\"2,909\",650"
    >>> res = re.findall(r"(\w+),(\d{2}/\d{2}/\d{4}),\"([\d,]+)\",\"([\d,]+)\",(\d+)", data)
    >>> res
    [('Place', '08/09/2010', '15,531', '2,909', '650')]
    

提交回复
热议问题