regex-pcre:我需要什么进口产品?

时间:2013-05-11 04:26:32

标签: haskell

我用 cabal 安装了我的第一个Haskell软件包:

$ cabal install regex-pcre

有人可以使用pcre regexes发布一个简单的例子,这样我就可以弄清楚我应该导入什么内容吗?

1 个答案:

答案 0 :(得分:2)

好的,我明白了。您需要的模块是Text.Regex.PCRE。对于POSIX正则表达式,它是Text.Regex.Posix。这是一个例子:

ghci>:m +Text.Regex.PCRE
ghci>"heeeee" =~ "hee|he*" :: [[String]]
Loading package array-0.4.0.0 ... linking ... done.
Loading package bytestring-0.9.2.1 ... linking ... done.
Loading package deepseq-1.3.0.0 ... linking ... done.
Loading package containers-0.4.2.1 ... linking ... done.
Loading package transformers-0.3.0.0 ... linking ... done.
Loading package mtl-2.1.2 ... linking ... done.
Loading package regex-base-0.93.2 ... linking ... done.
Loading package regex-pcre-0.94.4 ... linking ... done.
[["hee"]]

ghci>:m -Text.Regex.PCRE
ghci>:m +Text.Regex.Posix
ghci>"heeeee" =~ "hee|he*" :: [[String]]
Loading package regex-posix-0.95.2 ... linking ... done.
[["heeeee"]]