[英]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.