in reply to Why does split on /./ not split the string?
split returns only the string segments between, but not including the matching chars. For example:
my @list = split(/;/, 'one;two;three'); # @list is now ('one', 'two', 'three');
Since /./ matches on any char, what you end up with is essentially emptiness. The lookahead works because it is looking ahead, not "matching" in the same sense as /./. FYI: split(q//, $string); will split the string into chars, and is a little easier to understand (and possibly faster) than using /(?=.)/.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Why does split on /./ not split the string?
by QM (Parson) on Dec 07, 2005 at 19:59 UTC | |
by parv (Parson) on Dec 08, 2005 at 01:02 UTC | |
by QM (Parson) on Dec 08, 2005 at 04:39 UTC |