Hel*_*elp -25 regex haskell scope ghc
我在构建时遇到此错误:
dist/package.conf.inplace:
inappropriate type
FAILED DURING THE BUILDING PHASE. The **exception** was: ExitFailure 1
Run Code Online (Sandbox Code Playgroud)
如何subRegex 在 Text.Regex 包中使用?
我已经写了:
import Text.Regex.Posix
Run Code Online (Sandbox Code Playgroud)
但我得到了这个错误:
_.hs:13:5: Not in scope: ‘subRegex’
_.hs:13:15:
Not in scope: ‘mkRegex’
Perhaps you meant ‘makeRegex’ (imported from Text.Regex.Posix)
Run Code Online (Sandbox Code Playgroud)
所以,我去了Text.Regex[页] [1],然后说:
使用POSIX正则表达式接口
Text.Regex.Posix.
那么为什么不是这些功能在范围内呢?
以下是您可以执行的一些步骤.
:mod +Text.Regex以加载包.subRegex (mkRegex "[0-9]+") "foobar567" "123""foobar123"(在加载所有包之后).这是subRegex描述:
:: Regex Search pattern-> String Input string-> String Replacement text-> String Output string用替换字符串替换给定正则表达式的每个出现.
在替换字符串中,"\ 1"表示第一个子字符串; "\ 2"到第二个等; 和整个比赛的"\ 0"."\\"将插入一个文字反斜杠.
如果正则表达式匹配空字符串,则不会提前.此错误在此处与原始Text.Regex API的行为相匹配.
一些很酷的链接可以帮助您深入钻研:
http://www.serpentine.com/blog/2007/02/27/a-haskell-regular-expression-tutorial/和
https://wiki.haskell.org/ Cookbook/Pattern_matching.
我在Windows中使用它,这是我的屏幕:
