in reply to Regex - unordered lookaround syntax
Split is wrong when it's easier to talk about what you want to keep rather than what you want to throw away. For that, use a m//g in a list context. It looks like what you wanted to keep was any run of digits, or any run of letters. Hence, mine.my $string = "A BC 1 23DEF45 6"; my @parts = $string =~ /([a-zA-Z]+|\d+)/g;
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: •Re: Regex - unordered lookaround syntax
by halley (Prior) on Apr 29, 2003 at 00:28 UTC | |
by Anonymous Monk on Apr 29, 2003 at 04:56 UTC | |
by halley (Prior) on Apr 29, 2003 at 15:31 UTC | |
|
Re: •Re: Regex - unordered lookaround syntax
by shemp (Deacon) on Apr 28, 2003 at 23:04 UTC |