Regular expression query

Larry Martell larry.martell at gmail.com
Sun Mar 12 12:28:41 EDT 2017


On Sun, Mar 12, 2017 at 12:22 PM,  <rahulrasal at gmail.com> wrote:
> Hi All,
>
> I have a string which looks like
>
> aaaaa,bbbbb,ccccc "4873898374", ddddd, eeeeee "3343,23,23,5,,5,45", fffff "5546,3434,345,34,34,5,34,543,7"
>
> It is comma saperated string, but some of the fields have a double quoted string as part of it (and that double quoted string can have commas).
> Above string have only 6 fields. First is aaaaa, second is bbbbb and last is fffff "5546,3434,345,34,34,5,34,543,7".
> How can I split this string in its fields using regular expression ? or even if there is any other way to do this, please speak out.

Use the csv module:

https://docs.python.org/2.7/library/csv.html


More information about the Python-list mailing list