Question

Supposant J'ai une chaîne:

str = “ab,cd,ef” 

et je veux scinder en une liste

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

Comment puis-je faire mieux, en supposant que je ne sais pas à l'avance combien d'articles sont dans la chaîne?


En fait, je suis à la recherche d'un équivalent specman à Perl:

$str = "ab,cd,ef";
@lst = split /,/, $str;
Était-ce utile?

La solution

str_split est ce que vous voulez.

A partir Specman 6.1 docs:

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

Syntaxe Exemple

var s: list of string = str_split("first-second-third", "-"); 
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top