簡體   English   中英

Haskell和Regex - 為什么我的函數不能消除RedundantSpaces的工作?

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

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM