我正在尝试 Reason 并且我正在尝试使用正则表达式,但没有任何匹配项。AFAIK Reason 没有任何特定的正则表达式相关的东西,所以我只是离开 OCaml 文档。
我的字符串看起来像:
let name = "const {foo} = bar";
我正在使用的正则表达式是
let re = Str.regexp_string "\\bfoo\\b"
try {
Str.search_forward re name 0;
/* do something */
} {
| Not_found => acc
}
但我没有得到任何匹配。任何人都可以帮忙吗?
编辑:作为参考,OCaml 的正则表达式文档可以在https://caml.inria.fr/pub/docs/manual-ocaml/libref/Str.html找到。我使用http://pleac.sourceforge.net/pleac_ocaml/patternmatching.html作为 OCaml 正则表达式的示例,我无法让它工作。