in reply to regular expression paranthesis remover
This one's a freebie, thanks to Regexp::Common. You can read about using this module to match balanced parens by seeing the docs for Regexp::Common::balanced.
use strict; use warnings; use Regexp::Common qw/balanced/; my $string = '111(22(33)44)55'; $string =~ s/$RE{balanced}{-parens=>'()'}//g; print $string, "\n";
You can thank TheDamian and Abigail-II for all the hard work that went into this module.
Note: A regexp solution to matching balanced parens is probably less robust than a proper balanced text parser. For that, you could have a look at Text::Balanced.
Dave
|
|---|