" is used as a delimiter for each substring but also used as a special character inside each substring as /"
Is there an way to separate each substring based on the " delimiter with each substring containing \\" if any.
For example, String is:
"we don't care about \\"you\\" " "I don't care \\" \\"about." "I care about you"
Output:
"we don't care about \\"you\\"
"I don't care \\" \\"about."
"I care about you"
I tried:
re.findall(r'(?:\"(.*?)\")', string)
but I am unable to escape through \\".
Thanks a lot for your help.
The easy way might be:
s = '"HI in \"blah\"" "seconds" "\"thi\"rd"'
s[1:-1].split('" "')
# ['HI in "blah"', 'seconds', '"thi"rd']
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.