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
regex haskell


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


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics