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)
In reply to Re: Capturing substrings with complex delimiter, up to a maximum
by LanX
in thread Capturing substrings with complex delimiter, up to a maximum
by jkeenan1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |