[Haskell-cafe] Text.Regex.matchRegex: Success is empty?
kiss.csongor.kiss at gmail.com
Tue Apr 5 20:23:59 UTC 2016
It returns ‘Just’, because the pattern was found.
The list is empty, because no capture groups are defined in the regex.
matchRegex (mkRegex “(a)”) “abracadabra"
returns Just [“a”]
> On 5 Apr 2016, at 22:16, Jeffrey Brown <jeffbrown.the at gmail.com> wrote:
> Esteemed Haskellers,
> It is working for me, but I am puzzled by the matchRegex function:
> > import Text.Regex
> > :i matchRegex
> matchRegex :: Regex -> String -> Maybe [String]
> -- Defined in ‘Text.Regex’
> Searches that fail return Nothing:
> > matchRegex (mkRegex "z") "abracadabra"
> which makes sense. But why do searches that succeed return an empty list of Strings?
> > matchRegex (mkRegex "a") "abracadabra"
> Just 
> Jeffrey Benjamin Brown
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe