diff --git a/src/util/StringUtil.re b/src/util/StringUtil.re index 49a5cab22..582290e85 100644 --- a/src/util/StringUtil.re +++ b/src/util/StringUtil.re @@ -38,13 +38,7 @@ let split = Js_of_ocaml.Regexp.split; let plain_split: (string, string) => list(string) = (str, sep) => { - Js_of_ocaml.( - Js.string(str)##split(Js.string(sep)) - |> Js.str_array - |> Js.to_array - |> Array.to_list - |> List.map(Js.to_string) - ); + split(Js_of_ocaml.Regexp.regexp_string(sep), str); }; let to_lines = String.split_on_char('\n'); diff --git a/test/Test_StringUtil.re b/test/Test_StringUtil.re index b9c497337..fd2be69fd 100644 --- a/test/Test_StringUtil.re +++ b/test/Test_StringUtil.re @@ -37,5 +37,13 @@ let tests = ( StringUtil.plain_split("abbe", "b"), ) }), + test_case("regexp special character in separator", `Quick, () => { + check( + list(string), + "split", + ["a", "c"], + StringUtil.plain_split("a.*c", ".*"), + ) + }), ], );