Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by tye (Sage)
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        

Replies are listed 'Best First'.
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?
[Corion]: ... that can use templates from the HTML (via <script language="text/ template">... my template ...</script> and otherwise gets out of my way. But it seems that is not how the Javascript world is, currently :-/
[Corion]: I guess my question is, has anybody worked with React, Ember, Angular (v2, v4, v.whatever) or any other JS client-side dynamic rendering/virtual DOM thingie and found a simple, single-file solution like jQuery?

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (9)
As of 2017-03-27 19:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (321 votes). Check out past polls.