tags:

views:

143

answers:

2

[^a-zA-Z] - matches anything except a,b,c,...z , A, B, ..Z

I want 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??

A: 

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

Eric Kolb
+1  A: 

In your particular case, why don't you just make sure the "src" is inside the same tag?

Do something like <img\s[^>]*\bsrc

angus