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
also matches strings start escaped double quote. tried extend definition work negativ lookbehind.
(["'](?<!\\))(?:(?=(\\?))\2.)*?\1
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
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
Post a Comment