in reply to regular expression paranthesis remover
If you're unconcerned with their balancing except for the outer ones,
If they do balance, it works, too. What do you want to happen if they don't balance?$_ = '111(22(33)44)55'; my $re = qr/ (.*?) # minimal grab up to the first... \( # literal left paren .* # greedy skip everything up through... \) # the last literal right paren (.*)$ # then grab everything remaining /x; s/$re/$1$2/; print;
Update: Typo repaired, thanks, Hofmator.
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regular expression paranthesis remover
by Hofmator (Curate) on Jun 25, 2004 at 09:19 UTC | |
by thospel (Hermit) on Jun 25, 2004 at 12:26 UTC |