I want to be able to construct a regular expression which searches for a particular pattern in some HTML code where one parameter is negated (i.e. find x where y is NOT present).
Example: I want to find image width parameters where width does not equal “500”.
-
width="640" height="360"would match -
width="500" height="360"would NOT match
I’m using a search & replace plugin for wordpress to run the regular expression – http://urbangiraffe.com/plugins/search-regex – it just uses a generic regex syntax
I’m able to match simple queries but I’m afraid negation is a bit beyond me – any help would be much appreciated.
Thanks – David
You need to use a negative lookahead: