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;
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319

1 Answers1

2

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", "-"); 
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
Ross Rogers
  • 23,523
  • 27
  • 108
  • 164