
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-expr... Thanks for any help. Omari

It is even simpler than that. The type determines the return value.
"axxfayyf" =~ "a..f" :: Bool True
"axxfayyf" =~ "a..f" :: Int 2
"axxfayyf" =~ "a..f" :: String "axxf"
"axxfayyf" =~ "a..f" :: [[String]] [["axxf"],["ayyf"]]
"axxfayyf" =~ "a..f" :: [MatchArray] [array (0,0) [(0,(0,4))],array (0,0) [(0,(4,4))]]
"axxfayyf" =~ "a..f" :: (MatchOffset, MatchLength) (0,4)
Among other contexts specified in :i RegexContext
On Tue, Jul 20, 2010 at 11:55 AM, Omari Norman
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)]
Solved; do
getAllMatches ("foo" =~ "o") :: [(Int, Int)]
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Nevermind I see that you already knew that. But it is very cool anyways, I'm totally going to use regexes more often now that I've discovered it.
participants (2)
-
David McBride
-
Omari Norman