Tuesday, 15 February 2011

Haskell and Regex - Why doesn't my function eliminateRedundantSpaces work? -



Haskell and Regex - Why doesn't my function eliminateRedundantSpaces work? -

haskell , regex - why doesn't function eliminateredundantspaces work?

import text.regex eliminateredundantspaces text = subregex (mkregex "\\s+") text " "

text.regex uses posix regular expressions, , doesn't have \s abbreviation defined (that perl extension many other implementations have adopted). instead can utilize [:space:] character group, eg:

eliminateredundantspaces text = subregex (mkregex "[[:space:]]+") text " "

regex haskell

No comments:

Post a Comment