Regular match regular expressions for escaped characters

I process incoming data.

And it looks like this:

"Hello there are \"quotations\" that i wanna ignore" "other data I don't want"

"Selected this"  "other data I don't want"

I am currently using

^"[^\n]+?"

But he only captures. "Hello there are \" How can I give him the condition that his "with a \ precedes him?"

I need a regex that will capture the first "quoted part, but not other data"

I tried preg_match('/^"[^\n]+?[^\\]"/', $lines,$name);

Oh for php i used /^"[^\n]+?[^\\\\]"/

+3
source share
1 answer

Indicate that the character before the closing quote is not a backslash:

^"[^\n]+?[^\\]"
+2
source

All Articles