Regular expression to match text outside quotes, etc.

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

I went over to this regex to match all the lines quoted. It seems to work fine ... The problem is how to match text that is not in quotation marks. Inverse-non-negative somehow ...

I read the documentation and

 (?!(([\"'])(?:\\\\?+.)*?\\1)) 

does not work

+4
source share
1 answer

Hmm If the first regular expansion works, I would use it to remove all quoted strings from the input string. Then all that remains for you is the text that was outside the quotation line. With some types of templates, I find this approach much simpler and simpler.

+6
source

Source: https://habr.com/ru/post/1307345/


All Articles