Question

i'd like to split string with two or more ">", split function should brake string in first ">" and others put to second sting in list.

i try

$text = "tobash> hubba -> http://nonexists100101.net";

@op = split(/>{1}/, $text);

but split still breaks in every ">"

Was it helpful?

Solution

This is not how {1} works (in fact, {1} never does anything at all). According to perldoc split has a third limit parameter. Try:

split(/>/, $text, 2)

That will return at most 2 substrings.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top