regex - How can I match double-quoted strings with escaped double-quote characters? -


I need a Pearl Regular Expression to match a string. I only accept double quoted stars, that a word is a literal quote character and is not the end of the string, and that the character of a literal backslash and should not be escaped by a quotation character. , Then some examples:

"#" string is 1 character long, dobule quote "\\" # string is 1 character long, has a backslash in "\\\" "# string is 2 characters long From time to time, backslash and double quote "\\\" "# str I have 2 characters long, which has two backslashes

I need a regular expression that can recognize all these 4 possibilities, and other simple changes on all those possibilities, valid strings As for now what do I have:

  / ". * [^ \\] "/  

But this is not correct - it will not match anyone except before anyone. Does anyone give me a push in the right direction in this direction ?

How about this?

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

matches zero or more characters that are not slash or quotation or two slashes or a slash The quote


Comments