0

I'm doing a regex search through about 20,000 HTML files using SublimeText and trying to find out of certain CSS classes exist or not. Unfortunately, some classes are similarly named and I want to ignore those ones. For example, I'm looking for files that contain the class "refine search" but not ones that contain "txt_refine_search".

I tried refine_search(?!txt_refine_search) but it still found "txt_refine_search".

What query should I be using?

Kevin
  • 79
  • 7

1 Answers1

4

Your example of refine_search(?!txt_refine_search) searches for refine_search followed by txt_refine_search. As you found out, that won't work.

You may want to try a negative lookbehind. Sublime Text uses the PCRE flavor of regex, which does support lookbehind statements. It would look like (?<!txt_)refine_search and it would find refine_search not preceded by txt_.

Steven Doggart
  • 43,358
  • 8
  • 68
  • 105
Javier Conde
  • 2,553
  • 17
  • 25