Search code examples
regexsearchsublimetext3sublimetext

Search Sublime Text 3 for files that don't contain a specific string


Is it possible to carry out a search in Sublime Text 3 for files that don't contain the following string: 'include/config.php'?

This doesn't work:

(?!include/config.php)

Solution

  • You can't use an unanchored lookahead, it will be looking anywhere inside a text.

    Since ^ matches a beginning of a line, you'd rather use \A anchor that matches the beginning of the whole text.

    Also, you need to be able to check across newlines and text, thus, you need to enable a DOTALL mode with (?s) and use .* inside the lookahead.

    Also, to make sure we match whole words, use \b (word boundaries). And do not forget to escape the dot to match a literal dot.

    Use

    (?s)\A(?!.*\binclude/config\.php\b)