in reply to Re^2: Split string after 14 Line Feeds? (//g)
in thread Split string after 14 Line Feeds?
Indeed. I conflated two similar techniques: getting a list of matches from /(...)/g and getting a list of matches from /(...)(...)(...)/. You don't get a list of matches from /(...)*/ (nor from /(...)*/g).
What I should have written was:
my @chunks = $description =~ /\G((?:[^\n]*\n){14}|.+)/gs;
(tested even; works even)
Update: Changed last * to + to eliminate extra empty string in result that I just noticed which is due to "quirk" in Perl regex processing (something I think we should just 'fix', but that is a story for another node, one I've written at least once already).
- tye
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Split string after 14 Line Feeds? (//g)
by johnfl68 (Scribe) on Dec 04, 2012 at 07:41 UTC |