RegEx: Grabbing values between not escaped quotation marks -


this question related regex: grabbing values between quotation marks

the regex best answer

(["'])(?:(?=(\\?))\2.)*?\1 

tested the

debuggex demo

also matches strings start escaped double quote. tried extend definition work negativ lookbehind.

(["'](?<!\\))(?:(?=(\\?))\2.)*?\1 

debuggex demo

but not change in matched pattern. suggestions on how exclude escaped singe / double quotes starting pattern?

i want use highlighting pattern in nedit, supports regex-lookbehind.

example desired matching:

<p>    <span style="color: #ff0000">"str1"</span> notstr    <span style="color: #ff0000">"str2"</span>    \"notstr <span style="color: #ff0000">"str4"</span>  </p>

using negative lookbehind backslash not preceded backslash, i.e.

(?<!(?<!\\)\\)["'] 

solves problem:

((?<!(?<!\\)\\)["'])(?:(?=(\\?))\2.)*?(?<!(?<!\\)\\)\1 

demo.

you should careful approach, because regex not tool parsing inputs in markup syntax. better off using full-scale parser, , optionally applying regex parts it.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -