好的,尝试使用此正则表达式:
(text|simple)(?![^<]*>|[^<>]*</)
分解:
( # Open capture group text # Match 'text'| # Or simple # Match 'simple') # End capture group(?! # Negative lookahead start (will cause match to fail if contents match) [^<]* # Any number of non-'<' characters > # A > character| # Or [^<>]* # Any number of non-'<' and non-'>' characters </ # The characters < and /) # End negative lookahead.
负前瞻会阻止匹配,如果
text还是
simple是HTML标记之间。



