Does OCaml have String.split function like Python?

后端 未结 4 598
离开以前
离开以前 2021-01-12 01:24

I am using this to split strings:

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

But the problem

4条回答
  •  清酒与你
    2021-01-12 01:52

    This is how I split my lines into words:

    open Core.Std
    let tokenize line = String.split line ~on: ' ' |> List.dedup
    

    Mind the single quotes around the space character.

    Here's the documentation for String.split: link

提交回复
热议问题