I have a line in the following format:
s="part1,part2,part3,part4"
I can split the string into parts by simply calling the s.split(",") command.
Now the question is, what if I have a backslash in a string? Assuming I have the following line,
s="part1,part2,pa\\,rt3,part4"
I would like to get the result ["part1","part2","pa,rt3","part4"] .
It was originally intended to replace \, nonexistent string, then split the string with the split command and replace the nonexistent string with a comma.
Can you come up with a better way to deal with this problem?
source share