How to find (with reg expression) all files+folders with odd numbers of opening and closing brackets?

If you are experiencing problems with "Everything", post here for assistance.
Post Reply
pstein
Posts: 60
Joined: Thu Aug 07, 2014 6:18 pm

How to find (with reg expression) all files+folders with odd numbers of opening and closing brackets?

Post by pstein »

I want to find (with reg expression) all files+folders with odd numbers of opening and closing brackets.

That means that the following files should be found for example:

blah blah ( one two)) end.pdf
some.other ( file name ().txt

How should a regular expression look like?

The regexp should pay attention to the sequence of opening and closing brackets too.
So the file

asfdaf ( sdg sdgfsd )) sfgg ( sgsdf.dat

has the same number of opening and closing brackets but the sequence does not fit.
void
Developer
Posts: 17152
Joined: Fri Oct 16, 2009 11:31 pm

Re: How to find (with reg expression) all files+folders with odd numbers of opening and closing brackets?

Post by void »

Not possible with regex.

Please try the following search:

REGEXCOUNT($name:,"\(")!=REGEXCOUNT($name:,"\)")




2 levels of nesting with regex:
regex:\((?:[^()]*|\([^()]*\))*$


3 levels:
regex:\((?:[^()]*|\([^()]*\)|\((?:[^()]*|\([^()]*\))*\))*$
NotNull
Posts: 5517
Joined: Wed May 24, 2017 9:22 pm

Re: How to find (with reg expression) all files+folders with odd numbers of opening and closing brackets?

Post by NotNull »

pstein wrote: Wed Dec 04, 2024 8:20 am I want to find (with reg expression)
Why regex specifically? There are other solutions.
Post Reply