Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Capturing substrings with complex delimiter, up to a maximum

by BillKSmith (Priest)
on Oct 30, 2013 at 03:46 UTC ( #1060262=note: print w/replies, xml ) Need Help??


in reply to Capturing substrings with complex delimiter, up to a maximum

Remember that split takes a regex as it first argument. Use a lookahead assertion after the comma.
use strict; use warnings; use Data::Dumper; my $input = q|http://abc.org,http://de,f.org,https://ghi.org,http://jk +l.org|; my @urls = (split /,(?=http)/, $input, 4)[0..2]; print Dumper \@urls;
Output:
$VAR1 = [ 'http://abc.org', 'http://de,f.org', 'https://ghi.org' ];
Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1060262]
help
Chatterbox?
and the pool shimmers...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2017-02-22 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (323 votes). Check out past polls.