views:

126

answers:

1

Supposing I have a string:

str = “ab,cd,ef”

and I want to split it into a list

lst = [“ab”,”cd”,ef”]

How can I do it best, assuming that I don’t know ahead of time how many items are in the string?


Basically I'm looking for a specman equivalent to Perl's:

$str = "ab,cd,ef";
@lst = split /,/, $str;
+1  A: 

str_split is what you want.

From Specman 6.1 docs:

str_split(str: string, regular-exp: string): list of string

Syntax Example

var s: list of string = str_split("first-second-third", "-");
Ross Rogers