Regex for matching "but not \"

I always completely lose regular expressions, so I hope someone here can help.

Joomla uses this regular expression to check the lines of ini files:

/^(|(\[[^\]]*\])|([AZ][A-Z0-9_\-]*\s*=(\s*(("[^"]*")|(_QQ_)))+))\s*(;.*)?$/ 

Lines have this format.

 JLIB_LOGIN_AUTHENTICATE="Username and password do not match or you do not have an account yet." 

Obviously, " may not be allowed in terms of values, but may be \" . This currently matches the aforementioned regular expression. I see how this is consistent, but I canโ€™t change the regular expression so that it doesnโ€™t match. \" I tried to add |(\Q\"\E) to different places, but no luck.

+4
source share
2 answers

Change this:

  "[^"] * "

For this:

  "(\\" | [^ "]) *"

See how it works on the Internet: ideone

+6
source

replace [^"] with ([^"]|(\\"))

+3
source

All Articles