I want to find out a string in which a particular tag does not occur, such as:
<xyz>[\w]+<[^(unwanted)]></xyz>
where unwanted
will be interpreted as a
, d
, e
, n
, t
and u
. But what I want is a block string. How can I express it in regular expression?
I have tried negative lookahead, which doesn't work:
<xyz>.+(?!unwanted).+</xyz>
<xyz>(?:(?!unwanted).)+</xyz>
Matches all chars in <xyz>...</xyz>
, but only as long as the expression unwanted
doesn't start at any of them.
来源:https://stackoverflow.com/questions/14819125/regular-expression-block-negation