I need to split a string by space or by comma. But it should leave single or double quoted strings as it is. Even if it is apart by many spaces or a single space it makes no difference. For e.g.:
""" 1,' unchanged 1' " unchanged 2 " 2.009,-2e15 """
should return
""" 1,' unchanged 1'," unchanged 2 ",2.009,-2e15 """
There may be no or more spaces before and after a comma. Those spaces are to be ignored. In this particular context, as shown in the ex string, if two quoted or double quoted strings happen to be next to each other, they will have a space in between or a comma.
I have a previous question at python reg ex to include missing commas, however, for that to work a splitting comma should have a space after.
Aucun commentaire:
Enregistrer un commentaire