in reply to Re^2: AND and OR on Regular Expressions
in thread AND and OR on Regular Expressions

I would rather use:

$i++ while $pars =~ s/\(([^()]*)\)/$1/;

Better way is to use Regexp::Common and balanced pattern (not tested):

use Regexp::Common; $pars =~ /^[^()]*$RE{balanced}{-parens=>'()'}[^()]*$/

Replies are listed 'Best First'.
Re^4: AND and OR on Regular Expressions
by vitoco (Hermit) on Aug 26, 2009 at 14:51 UTC

    The first regexp I thought for the while was the same as yours, which is syntactically correct, since it removes the matching parenteses, starting from the inner ones when nested. But used the other regexp because I think it's faster, and nothing will be done with the remaining string other than to look if there is at least one of the parentheses remaining.

    Using the balanced option of that module sound interesting, but, again, I think that my problem was easy enougth to try an external pattern that calls another subroutine, which is able to manage multiple delimiters.

    I'm still viewing the available regexp modules' docs in CPAN, looking for one that does all I did here at the same time.

    Anyway, thank you for the hints!!!