2

[^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?

Unihedron
  • 10,902
  • 13
  • 62
  • 72
nishant
  • 29
  • 1
  • 3

2 Answers2

2

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
  • 2,305
  • 1
  • 15
  • 22
1

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
  • 996
  • 6
  • 9