in reply to regex trouble
This is a pretty straightforward thing to do. I'd break up the construction of $pattern in to steps:
[trwww@www misc]$ cat 618115.pl use warnings; use strict; my @delimiters = ( ',', '|', ':', '>', '][', '_|_', ); my $pattern = join '|', map quotemeta, @delimiters; my $text = "jojo,has|some:big>balls][nuts,sometimes_|_he,scratches"; foreach my $particle (split /$pattern/, $text) { print $particle."\n"; }
That gives the following output:
[trwww@www misc]$ perl 618115.pl jojo has some big balls nuts sometimes he scratches
Hope this helps,
trwww
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: regex trouble
by dewey (Pilgrim) on May 30, 2007 at 16:43 UTC | |
by graff (Chancellor) on May 31, 2007 at 03:32 UTC | |
by dewey (Pilgrim) on May 31, 2007 at 14:37 UTC |