in reply to Removing only the first instance with RegEx
#!/usr/bin/perl use strict; use warnings; my $bal; $bal = qr /[^()]* (?: [(] (??{ $bal }) [)] )* [^()]*/x; while (<DATA>) { chomp; print $& while /$bal/g; print "\n"; } __DATA__ (1.3.56.84 56.38.m.26) (56.2.3.59) ((one)(two)) ((one(two)) ((one)(two) (one)(two)) ((one)two))
Running this gives:
1.3.56.84 56.38.m.26 (56.2.3.59) ((one)(two)) (one(two)) (one)(two) (one)(two) ((one)two)
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Removing only the first instance with RegEx
by Anonymous Monk on Nov 06, 2003 at 14:22 UTC | |
by Abigail-II (Bishop) on Nov 06, 2003 at 14:29 UTC | |
by Anonymous Monk on Nov 06, 2003 at 14:33 UTC |