Monday, September 14, 2015

Regex - Contains THIS String But Not THAT String

Here's a regular expression that will return lines that have THIS string but not THAT string:


THIS(?!.*?THAT)

Example

This could be useful if you are searching for tables that do not have the id attribute:


\<table(?!.*?id)




This work is licensed under the Creative Commons Attribution 3.0 Unported License.

No comments:

Post a Comment