小编use*_*111的帖子

(ReasonML)正则表达式\ b不匹配

我正在尝试Reason并且我正在尝试使用正则表达式,但没有任何匹配.AFAIK Reason没有任何特定的正则表达式相关的东西,所以我只是关闭OCaml文档.

我的字符串看起来像:

let name = "const {foo} = bar";
Run Code Online (Sandbox Code Playgroud)

我正在使用的正则表达式是

let re = Str.regexp_string "\\bfoo\\b"
try {
  Str.search_forward re name 0;
  /* do something */
} {
 | Not_found => acc
}
Run Code Online (Sandbox Code Playgroud)

但我没有得到任何比赛.有人可以帮忙吗?

编辑:作为参考,可以在https://caml.inria.fr/pub/docs/manual-ocaml/libref/Str.html找到OCaml的正则表达式文档.我使用http://pleac.sourceforge.net/pleac_ocaml/patternmatching.html作为OCaml正则表达式的一个例子我无法让它工作.

regex ocaml reason

2
推荐指数
1
解决办法
637
查看次数

标签 统计

ocaml ×1

reason ×1

regex ×1