module Text.Regex.Do.Pcre.Match
(Match(..),
R.extract,
makeRegexOpts) where
import qualified Text.Regex.Base.RegexLike as R hiding (makeRegex)
import Text.Regex.Do.TypeDo
import Text.Regex.Do.Pcre.Option as O
import Text.Regex.Do.TypeRegex
import Text.Regex.Do.Pcre.Matchf as F
import Text.Regex.PCRE.Wrap()
class Match a b out where
match::Pattern a -> Body b -> out
(=~)::a -> b -> out
(=~) p0 b0 = match (Pattern p0) (Body b0)
instance Rx_ a b => Match a b [b] where
match = once
instance Rx_ a b => Match a b Bool where
match p0 (Body b0) = R.matchTest (r_ p0) b0
instance Rx_ a b => Match a b [[b]] where
match = F.all
instance Rx_ a b => Match a b [PosLen] where
match p0 b0 = maybe [] id $ poslen_ p0 b0
instance Rx_ a b => Match a b [[PosLen]] where
match = poslen_
makeRegexOpts::Opt_ a =>
[O.Comp] -> [O.Exec] -> Pattern a -> Regex
makeRegexOpts comp0 exec0 (Pattern pat0) = rx1
where c1 = O.comp comp0
e1 = O.exec exec0
rx1 = R.makeRegexOpts c1 e1 pat0