[英]Haskell and Regex - Why doesn't my function eliminateRedundantSpaces work?
Haskell和Regex - 为什么我的函数不能消除RedundantSpaces的工作?
import Text.Regex
eliminateRedundantSpaces text =
subRegex (mkRegex "\\s+") text " "
Text.Regex
使用Posix正则表达式 ,并且没有定义\\s
缩写(这是许多其他实现已采用的perl扩展)。 相反,您可以使用[:space:]
字符组,例如:
eliminateRedundantSpaces text =
subRegex (mkRegex "[[:space:]]+") text " "
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.