Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我有一个字符串:
str = “ab,cd,ef”
我想把它分成一个列表
lst = [“ab”,”cd”,ef”]
假设我不提前知道字符串中有多少项,我怎样才能做到最好?
基本上我正在寻找一个与 Perl 相当的规范:
$str = "ab,cd,ef"; @lst = split /,/, $str;
str_split 是你想要的。
来自 Specman 6.1 文档:
str_split(str: string, regular-exp: string): list of string
语法示例
var s: list of string = str_split("first-second-third", "-");