[Haskell-cafe] Regex multiple matches
David McBride
dmcbride at neondsl.com
Tue Jul 20 16:47:18 EDT 2010
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 <omari at smileystation.com>wrote:
> > 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100720/a5dfc2de/attachment.html
More information about the Haskell-Cafe
mailing list