I'm trying to split an extremely long string by commas. I have two requirements, however:
- the comma cannot be followed by a space
- the comma cannot be followed by a '+' symbol
so for example, the input would be:
text = "hello,+how are you?,I am fine, thanks"
and the output of this is:
['hello,+how are you?', 'I am fine, thanks']
i.e. the only comma that seperated the values was the one that was not followed by a '+' or a space
I have managed requirement 1) as follows:
re.split(r',(?=[^\s]+)',text)
I cannot figure out how to add requirement 2)