OCaml中的正则表达式 [英] Regular Expressions in OCaml

查看:106
本文介绍了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.

我不知道这是什么问题,Str应该是标准模块(根据

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆