last day (14 days later) » 

5:50 AM
1
A: Parse a string from a string with regex

Avinash RajYou could try the below regex to match the strings that starts with " (which was not preceded by \ symbol) upto the next " symbol which also not preceded by \ (?<!\\)".*?(?<!\\)" DEMO >>> s = r'"a string" ... "another \"string\"" ... "yet another \"string" ... "failed string\"' >>> m = re.fin...

 
That works to an extent but I added a second case that I had forgot about before, that being the literal backslash character before quotes. Please refer the the OP and if you could help out that would be great.
 
@globby updated... it's the python behaviour of escaping the backslash one more time.
 
Actually, I figured it out myself. Thanks. Used (?<!(?<!\\)\\)".*?(?<!(?<!\\)\\)"
 
nice, attempt..
 
I don't believe that is relevant, due to the fact that I didn't need it to match that case ;p
 
do you have any further problem?both regexes matches the same set of words i think..
 
regex101.com/r/sX9fR0/8 This breaks yours
Actually
it breaks mine too
I take that back
They both match the same
Sorry for the confusion, I don't know what I was thinking.
Thank you for the reply.
 
you're welcome ...
 

last day (14 days later) »