I'm trying to split a string into a list using a separator (say,), but the separator character should be considered as a separator only if it is not wrapped in a specific pattern, in my particular case <> , IOW, when the comma is nested in <> , it is ignored as a separator and becomes just a regular character, which should not be limited.
So, if I have the following line:
"first token, <second token part 1, second token part 2>, third token"
he must break into
list[0] = "first token" list[1] = "second token part 1, second token part 2" list[2] = "third token"
Needless to say, I can't just make a simple split into , because it will split the second token into two tokens, second token part 1 and second token part 2 , since they have a comma between them.
How to define a template for this using Python RegEx ?
source share