Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find a file NOT containing a string in SublimeText3 or Atom

I am trying to find files that don't contain string in the project finder of sublime.

I tried: ^((?!string))*$ but it returns all files that include the string. Any way to get this to work?

My use case

I have a bunch of svg files (>400) and and they should all have a class called icons-background in them somewhere. Now I just want to find the svg files that don't have that class and fix them.

should match

<svg viewBox="0 0 32 32">
    <path fill="#20262d" d="M23.8 0c3.5 6.4 4.2 16-9.8"></path>
</svg>

shouldn't match

<svg viewBox="0 0 32 32">
    <path fill="#20262d" class="icons-background" d="M23.8 0c3.5 6.4 4.2 16-9.8"></path>
</svg>

What I get currently

enter image description here

Work around

What I ended up using is a bash command:

find .  -type f -wholename "*/svg/*.svg" -not -path "*/node_modules/*" -exec grep -L -H 'icons-background' '{}' ';'

I keep this question open however in case someone finds a solution for one of those editors.

like image 886
Dominik Avatar asked Feb 03 '26 09:02

Dominik


1 Answers

Try this:

^((?!class="icons-background").)*$

You can explore this regex using the link below:

Regex101

like image 174
Tim Biegeleisen Avatar answered Feb 05 '26 03:02

Tim Biegeleisen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!