I ultimately want to split a string by a certain character. I tried Regex, but it started escaping \
, so I want to avoid that with another approach (all the attempts at unescaping the string failed). So, I want to get all positions of a character char
in a string that is not within quotes, so I can split them up accordingly.
For example, given the phase hello-world:la\test
, I want to get back 11
if char
is :
, as that is the only :
in the string, and it is in the 11th index. However, re
does split it, but I get ['hello-world
,lat\\test']
.
EDIT
:
@BoarGules made me realize that re
didn't actually change anything, but it's just how Python displays slashes.