OCaml是否具有像Python这样的String.split函数?

问题描述:

我正在使用它来分割字符串:

I am using this to split strings:

 let split = Str.split (Str.regexp_string " ") in
   let tokens = split instr in
 ....

但是问题是,例如,这是我要解析的句子:

But the problem is that for example here is a sentence I want to parse:

pop     esi

,拆分后变成(我使用辅助函数来打印tokens列表中的每个项目):

and after the split it turns to be (I use a helper function to print each item in the tokens list):

item: popitem: item: item: item: esi

请参阅,令牌列表中有三个空格.

See, there are three spaces in the token list.

我想知道是否有像Python这样的string.split可以通过这种方式解析instr:

I am wondering if there is a string.split like in Python which can parse instr this way:

item: popitem: esi

有可能吗?

不要使用Str.regexp_string,它仅用于匹配固定字符串.

Don't use Str.regexp_string, it's only for matching fixed strings.

使用Str.split (Str.regexp " +")