Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by johnfl68 (Scribe)
on Dec 04, 2012 at 05:11 UTC ( [id://1006997]=note: print w/replies, xml ) Need Help??


in reply to Re: Split string after 14 Line Feeds? (//g)
in thread Split string after 14 Line Feeds?

Thanks. I think I see where you are going with this, but the array is coming up empty. I'll try and go over it again, regex's make my head hurt. :(
  • Comment on Re^2: Split string after 14 Line Feeds? (//g)

Replies are listed 'Best First'.
Re^3: Split string after 14 Line Feeds? (//g)
by tye (Sage) on Dec 04, 2012 at 05:24 UTC

    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        

      Thank you very much! That works great!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2024-04-26 07:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found