2013-05-11 43 views
0

我安装我的第一个Haskell包阴谋regex-pcre:我需要什么进口?

$ cabal install regex-pcre 

可以用正则表达式PCRE所以我可以找出我应该导入有人张贴一个简单的例子?

+0

好吧,我想通了: – 7stud 2013-05-11 04:35:59

+0

有疑问时,看看[Hackage页](http://hackage.haskell.org/package/regex-pcre-0.94.4 )为包;它通常会有文档,但至少会列出公开的模块。 – isturdy 2013-05-11 08:08:10

+0

@isturdy在展示如何真正使用这个库方面,我没有找到那个有用的Hackage页面。 – Desty 2015-08-25 19:45:28

回答

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"]]