[^a-zA-Z]
matches anything except a, b, c, .. z, A, B, .. Z
I want the expression that matches anything except (abc)
and except (xyz)
I want a regex for image tag.
I tried img.*src
- it matches the initial part but between img
and src
there should not be any other image tag so I put a caret img[^(neither <img nor src=)]
how to use ^
with a group of characters?
In your particular case, why don't you just make sure the "src" is inside the same tag?
Do something like <img\s[^>]*\bsrc
Based on the scenario you're describing, it sounds like you want to use a look-ahead instead of a character exclusion.
MatchThis\s*(?!DontMatchThis|OrThis)
This will match "MatchThis", but not if it is is followed by "DontMatchThis" or by "OrThis"
Here's a link if you'd like to learn more about look-aheads and look-behinds in regular expressions: http://www.regular-expressions.info/lookaround.html
精彩评论