2013-05-11 52 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"]]