OCaml中的正则表达式 [英] Regular Expressions in OCaml
问题描述
我想在OCaml中使用 regexps ,看来Str
模块提供了这些功能.
I want to use regexps in OCaml and it seems that Str
module provides these functionalities.
所以我尝试了一个简单的程序:
So I tried with a simple program:
open Str
let regx = regexp "."
但是它给了我以下错误
文件"lol.ml",第1行,字符0-1: 错误:链接lol.cmo时出错: 引用未定义的全局'Str'
File "lol.ml", line 1, characters 0-1: Error: Error while linking lol.cmo: Reference to undefined global `Str'
好像没有模块,但是如果我删除了open Str
,它说regexp
是一个未绑定的值.
As if module is not present but if I remove open Str
it says that regexp
is an unbound value.
I don't get what kind of issue it is, Str
should be a standard module (according to http://caml.inria.fr/pub/docs/old-311/libref/Str.html) so I'm clueless.. the only think I thought is that signature (mli
) is present but implementation (ml
) is not.
我正在根据ocaml
工具运行Objective Caml version 3.11.0
.
有人可以帮我解决这个问题吗? 预先感谢
Can anyone help me figuring this out? Thanks in advance
推荐答案
来自手册:
使用str库的程序必须按以下方式链接:
Programs that use the str library must be linked as follows:
ocamlc other options str.cma other files
ocamlopt other options str.cmxa other files
这篇关于OCaml中的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!