How to split string with multiple delimiters and find out which delimiter was used to split the string with a maxsplit of 1.
import re
string ="someText:someValue~"
re.split(":|~",string,1)
returns ['someText', 'someValue~']
. In this case ":" was the delimiter to split the string.
If string is string ="someText~someValue:"
, then "~" will be delimiter to split the string
Is there a way to find out which delimitor was used and store that in a variable.
PS: someText and someValue may contain special chars, that are not used in split. Eg: some-Text, some_Text, some$Text