Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
$x = '12aba34ba5';
@num = split /(a|b)+/, $x;
# @num = ('12','a','34','b','5')
@num = split /(?:a|b)+/, $x;
# @num = ('12','34','5')
Well...
I can't quite work my way around the first "split" operation.
Also, it appears that @num = ('12', 'a', '34', 'a', '5'), i.e., 'a' as the 4th element, and not 'b', as specified.
I'd really appreciate it, if someone could perhaps explain how the above 'split' operation actually works.
Thank you!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regexp - groupings
by hexcoder (Curate) on Aug 02, 2008 at 21:18 UTC | |
|
Re: Regexp - groupings
by harleypig (Monk) on Aug 02, 2008 at 23:14 UTC | |
|
Re: Regexp - groupings
by eosbuddy (Scribe) on Aug 03, 2008 at 00:54 UTC | |
|
Re: Regexp - groupings
by ikegami (Patriarch) on Aug 03, 2008 at 05:26 UTC |