[Haskell-cafe] Regex multiple matches

Omari Norman omari at smileystation.com
Tue Jul 20 10:01:53 EDT 2010


Hi,

How do I use Text.Regex.PCRE to get information on multiple matches? For
instance, in ghci I get this error message:

Prelude Text.Regex.PCRE> "foo" =~ "o" :: [(Int,Int)]

<interactive>:1:0:
    No instance for (RegexContext Regex [Char] [(Int, Int)])
      arising from a use of `=~' at <interactive>:1:0-11
    Possible fix:
      add an instance declaration for
      (RegexContext Regex [Char] [(Int, Int)])
    In the expression: "foo" =~ "o" :: [(Int, Int)]
    In the definition of `it': it = "foo" =~ "o" :: [(Int, Int)]

"Real World Haskell"'s text suggests this should work, but the ghci
output is littered with errors.

http://book.realworldhaskell.org/read/efficient-file-processing-regular-expressions-and-file-name-matching.html

Thanks for any help.
Omari


More information about the Haskell-Cafe mailing list