Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Split string after 14 Line Feeds? (//g)

by tye (Cardinal)
on Dec 04, 2012 at 05:24 UTC ( #1006999=note: print w/ replies, xml ) Need Help??


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        


Comment on Re^3: Split string after 14 Line Feeds? (//g)
Download Code
Re^4: Split string after 14 Line Feeds? (//g)
by johnfl68 (Beadle) on Dec 04, 2012 at 07:41 UTC
    Thank you very much! That works great!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006999]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (9)
As of 2015-07-07 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (88 votes), past polls