Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; while (<DATA>) { $_ =~ s/[(]*(?![)]+)//; $_ =~ s/[)]*(?<![(])//; print $_, "\n"; } __DATA__ (1.3.56.84 56.38.m.26) 56.2.3.(59)
Any help would be appreciated$_ =~ s/[(]*(?![)]+)//; # Replace 0 or more instances of '(' if the # lookahead assertion for one or more of ')' # fails. This seems to work correctly $_ =~ s/[)]*(?<![(])//; # Replace 0 or more instances of ')' if the # lookbehind assertion for '(' fails. This # doesn't work as I though.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extended Regex Sequences
by TomDLux (Vicar) on Nov 06, 2003 at 16:13 UTC | |
|
Re: Extended Regex Sequences
by jryan (Vicar) on Nov 06, 2003 at 16:01 UTC | |
|
Re: Extended Regex Sequences
by Anonymous Monk on Nov 06, 2003 at 16:41 UTC |