Haskell and Regex - Why doesn't my function eliminate RedundantSpaces?
Haskell and Regex - Why doesn't my function eliminate RedundantSpaces?
import Text.Regex
eliminateRedundantSpaces text =
subRegex (mkRegex "\\s+") text " "
+3
Juan carlos kuri pinto
source
to share
1 answer
Text.Regex
uses Posix regular expressions and does not contain a shorthand acronym \s
(this is a perl extension that many other implementations do). You can use a group of characters instead [:space:]
, like:
eliminateRedundantSpaces text =
subRegex (mkRegex "[[:space:]]+") text " "
+10
David Miani
source
to share