How to split but ignore separators in quoted strings, in python?
- by Sly
I need to split a string like this, on semicolons. But I don't what to split on semicolons that are inside of a string (' or "). I'm not parsing a file; just a simple string with no line breaks.
part 1;"this is ; part 2;";'this is ; part 3';part 4
Result should be:
part 1
"this is ; part 2"
'this is ; part 4'
part 4
I suppose this can be done with a regex but if not; I'm open to another approach.