我正在尝试编写一条正则以找到所有出现的'字符,但排除了以[or<并以]或>。
结尾这是一个模范文字:
This is some text with ' character to find and [text to 'exclude' with letters and numbers 0-9 '' ] and another part of text with 'more characters' to find <and 'more to' exclude> and again some text with 'character' to find
我尝试了带负lookahead的正则态度:
(?!(([|<)[sS]*?(]|>)))'
但是它不起作用。
几个小时后,我用完了想法:(。任何帮助将不胜感激。
您可以使用
[.*?]|<.*?>|(')
并使用捕获的组(请参见Regex101.com 上的演示)或如果您的引擎(PHP,Perl,PCRE一般,...)使用 请参阅后者的演示。(*SKIP)(*FAIL)
版本支持:(?:[.*?]|<.*?>)(*SKIP)(*FAIL)|'