I am trying to split a string by commas “,”
For example:
"hi, welcome" I would like to produce ["hi","welcome"]
however:
"'hi,hi',hi" I would like to produce ["'hi,hi'","hi"]
"'hi, hello,yes','hello, yes','eat,hello'" I would like to produce ["'hi, hello,yes'","'hello, yes'","'eat,hello'"]
"'hiello, 332',9" I would like to produce ["'hiello, 332'","9"]
I dont think the .split() function could be used, Does anyone know a way I could do this, perhaps with regex?
You can use the csv module with the
quotecharargument, or you can convert your inputs to use the more standard"character for their quote character.