0 votes

I would like to find files that do not contain a string. For example, I want to find all files without the text "fubar". The regex wizard steps me through finding files that contain text 0 or 1 times, or once, or once or more times, but not zero times. Maybe it would be a boolean regex but I can't seem to find the syntax to do this. Help? TIA.

FileLocator Pro 7.2

by (65 points)

2 Answers

+1 vote

You could use the Boolean expression:

NOT "fubar"
by (30.1k points)

In the example, you'll notice I'm checking that the entire string, "bizobj =" is on one line in the file, hence the regex bol and eol matching. But, otherwise, if it's just a straightforward string, you would be correct.

ETA: The reason I think my solution might be silly is because I keep thinking there is a (PERL) regex expression for a string occurring exactly zero times, like there is a way to specify a string match exactly once.

Cool, just a small trick you might not know. The expression: NOT REGEX "(^bizobj = $)" would be the same as yours.

0 votes

I found a way, though it may be a ridiculous solution, it's working. I did the following.

  1. Chose Boolean Regex type for the contents,
  2. Selected "Across whole file" on Options tab
  3. Entered the following in the Containing text field: "(^bizobj = $)?" AND NOT "(^bizobj = $)"

The first clause finds the lines with 0 or 1 matches. The second close excludes the matches with 1 or more matches.

by (65 points)
...