May-11-2020, 01:53 PM
Putting a title on this was hard so hopefully I can do a better job of explaining it here.
Let's say I had a string like this:
I would like to be able to split those strings with multiple delimiters, but keep the strings "intact" like this: string A would become:
string B would become:
As you can see, each string is split with multiple delimiters, but the "chains of characters" are intact rather than it appearing like:
The closest I have gotten is using re.split with a delimiter like (.|n|d|9) but that produces an array like:
How could I get this to work? Is using re.split even the best way?
Let's say I had a string like this:
.nnddd9999999999ddnn. (A) or like this: ''0000aaa0000'' (B)I would like to be able to split those strings with multiple delimiters, but keep the strings "intact" like this: string A would become:
['.', 'nn', 'ddd', '9999999999', 'ddd', 'nn', '.']string B would become:
['\'\'', '0000', 'aaa', '0000', '\'\'']As you can see, each string is split with multiple delimiters, but the "chains of characters" are intact rather than it appearing like:
['.', 'n', 'n', 'd', 'd', 'd', '9', '9', '9'...]The closest I have gotten is using re.split with a delimiter like (.|n|d|9) but that produces an array like:
['.', '', 'n', '', 'n', '', 'd', ''...]How could I get this to work? Is using re.split even the best way?
