in reply to Capturing substrings with complex delimiter, up to a maximum
DB<107> $str=join ",",@captures => "http://abc.org,http://de,f.org,https://ghi.org" DB<108> split /,(?=https?:)/,$str,1 => "http://abc.org,http://de,f.org,https://ghi.org" DB<109> split /,(?=https?:)/,$str,2 => ("http://abc.org", "http://de,f.org,https://ghi.org") DB<110> split /,(?=https?:)/,$str,3 => ("http://abc.org", "http://de,f.org", "https://ghi.org")
you just need to get rid of the unsplitted rest (if any)
DB<122> $n=1 => 1 DB<123> @array[0..$n-1] = split /,(?=https?:)/ , $str , $n+1 => "http://abc.org" DB<124> $n=2 => 2 DB<125> @array[0..$n-1] = split /,(?=https?:)/ , $str , $n+1 => ("http://abc.org", "http://de,f.org")
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Capturing substrings with complex delimiter, up to a maximum
by jkeenan1 (Deacon) on Oct 30, 2013 at 01:33 UTC |