regex-with-pcre 0.8.0.0 → 0.9.0.0
raw patch · 9 files changed
+562/−252 lines, 9 filesdep ~regexPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: regex
API changes (from Hackage documentation)
- Text.RE.PCRE.RE: defaultOptions :: Options
- Text.RE.PCRE.RE: instance Text.RE.Types.Options.IsOption () Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: instance Text.RE.Types.Options.IsOption (Text.RE.Types.Options.Macros Text.RE.PCRE.RE.RE) Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: instance Text.RE.Types.Options.IsOption Text.RE.PCRE.RE.Options Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: instance Text.RE.Types.Options.IsOption Text.RE.Types.Options.SimpleRegexOptions Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: instance Text.RE.Types.Options.IsOption Text.Regex.PCRE.Wrap.CompOption Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: instance Text.RE.Types.Options.IsOption Text.Regex.PCRE.Wrap.ExecOption Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
- Text.RE.PCRE.RE: noPreludeOptions :: Options
- Text.RE.PCRE.RE: type Options = Options_ RE CompOption ExecOption
- Text.RE.PCRE.RE: unpackSimpleRegexOptions :: SimpleRegexOptions -> Options
+ Text.RE.PCRE: (*=~/) :: IsRegex RE s => s -> SearchReplace RE s -> s
+ Text.RE.PCRE: (?=~/) :: IsRegex RE s => s -> SearchReplace RE s -> s
+ Text.RE.PCRE: BlockInsensitive :: SimpleREOptions
+ Text.RE.PCRE: BlockSensitive :: SimpleREOptions
+ Text.RE.PCRE: MultilineInsensitive :: SimpleREOptions
+ Text.RE.PCRE: MultilineSensitive :: SimpleREOptions
+ Text.RE.PCRE: allMatches :: Matches a -> [Match a]
+ Text.RE.PCRE: anyMatches :: Matches a -> Bool
+ Text.RE.PCRE: compileRegex :: (Functor m, Monad m) => String -> m RE
+ Text.RE.PCRE: compileRegexWith :: (Functor m, Monad m) => SimpleREOptions -> String -> m RE
+ Text.RE.PCRE: countMatches :: Matches a -> Int
+ Text.RE.PCRE: data Match a :: * -> *
+ Text.RE.PCRE: data Matches a :: * -> *
+ Text.RE.PCRE: data RE
+ Text.RE.PCRE: data SimpleREOptions :: *
+ Text.RE.PCRE: escape :: (Functor m, Monad m) => (String -> String) -> String -> m RE
+ Text.RE.PCRE: escapeWith :: (Functor m, Monad m) => SimpleREOptions -> (String -> String) -> String -> m RE
+ Text.RE.PCRE: matchSource :: Match a -> a
+ Text.RE.PCRE: matched :: Match a -> Bool
+ Text.RE.PCRE: matchedText :: Match a -> Maybe a
+ Text.RE.PCRE: matches :: Matches a -> [a]
+ Text.RE.PCRE: matchesSource :: Matches a -> a
+ Text.RE.PCRE: reSource :: RE -> String
+ Text.RE.PCRE.ByteString: (*=~/) :: ByteString -> SearchReplace RE ByteString -> ByteString
+ Text.RE.PCRE.ByteString: (?=~/) :: ByteString -> SearchReplace RE ByteString -> ByteString
+ Text.RE.PCRE.ByteString: BlockInsensitive :: SimpleREOptions
+ Text.RE.PCRE.ByteString: BlockSensitive :: SimpleREOptions
+ Text.RE.PCRE.ByteString: MultilineInsensitive :: SimpleREOptions
+ Text.RE.PCRE.ByteString: MultilineSensitive :: SimpleREOptions
+ Text.RE.PCRE.ByteString: allMatches :: Matches a -> [Match a]
+ Text.RE.PCRE.ByteString: anyMatches :: Matches a -> Bool
+ Text.RE.PCRE.ByteString: countMatches :: Matches a -> Int
+ Text.RE.PCRE.ByteString: data Match a :: * -> *
+ Text.RE.PCRE.ByteString: data Matches a :: * -> *
+ Text.RE.PCRE.ByteString: data SimpleREOptions :: *
+ Text.RE.PCRE.ByteString: escapeWith :: (Functor m, Monad m) => SimpleREOptions -> (String -> String) -> String -> m RE
+ Text.RE.PCRE.ByteString: matchSource :: Match a -> a
+ Text.RE.PCRE.ByteString: matched :: Match a -> Bool
+ Text.RE.PCRE.ByteString: matchedText :: Match a -> Maybe a
+ Text.RE.PCRE.ByteString: matches :: Matches a -> [a]
+ Text.RE.PCRE.ByteString: matchesSource :: Matches a -> a
+ Text.RE.PCRE.ByteString.Lazy: (*=~/) :: ByteString -> SearchReplace RE ByteString -> ByteString
+ Text.RE.PCRE.ByteString.Lazy: (?=~/) :: ByteString -> SearchReplace RE ByteString -> ByteString
+ Text.RE.PCRE.ByteString.Lazy: BlockInsensitive :: SimpleREOptions
+ Text.RE.PCRE.ByteString.Lazy: BlockSensitive :: SimpleREOptions
+ Text.RE.PCRE.ByteString.Lazy: MultilineInsensitive :: SimpleREOptions
+ Text.RE.PCRE.ByteString.Lazy: MultilineSensitive :: SimpleREOptions
+ Text.RE.PCRE.ByteString.Lazy: allMatches :: Matches a -> [Match a]
+ Text.RE.PCRE.ByteString.Lazy: anyMatches :: Matches a -> Bool
+ Text.RE.PCRE.ByteString.Lazy: countMatches :: Matches a -> Int
+ Text.RE.PCRE.ByteString.Lazy: data Match a :: * -> *
+ Text.RE.PCRE.ByteString.Lazy: data Matches a :: * -> *
+ Text.RE.PCRE.ByteString.Lazy: data SimpleREOptions :: *
+ Text.RE.PCRE.ByteString.Lazy: escapeWith :: (Functor m, Monad m) => SimpleREOptions -> (String -> String) -> String -> m RE
+ Text.RE.PCRE.ByteString.Lazy: matchSource :: Match a -> a
+ Text.RE.PCRE.ByteString.Lazy: matched :: Match a -> Bool
+ Text.RE.PCRE.ByteString.Lazy: matchedText :: Match a -> Maybe a
+ Text.RE.PCRE.ByteString.Lazy: matches :: Matches a -> [a]
+ Text.RE.PCRE.ByteString.Lazy: matchesSource :: Matches a -> a
+ Text.RE.PCRE.RE: compileSearchReplace :: (Monad m, Functor m, IsRegex RE s) => String -> String -> m (SearchReplace RE s)
+ Text.RE.PCRE.RE: compileSearchReplaceWith :: (Monad m, Functor m, IsRegex RE s) => SimpleREOptions -> String -> String -> m (SearchReplace RE s)
+ Text.RE.PCRE.RE: compileSearchReplaceWithREOptions :: (Monad m, Functor m, IsRegex RE s) => REOptions -> String -> String -> m (SearchReplace RE s)
+ Text.RE.PCRE.RE: defaultREOptions :: REOptions
+ Text.RE.PCRE.RE: ed :: QuasiQuoter
+ Text.RE.PCRE.RE: edBI :: QuasiQuoter
+ Text.RE.PCRE.RE: edBS :: QuasiQuoter
+ Text.RE.PCRE.RE: edBlockInsensitive :: QuasiQuoter
+ Text.RE.PCRE.RE: edBlockSensitive :: QuasiQuoter
+ Text.RE.PCRE.RE: edMI :: QuasiQuoter
+ Text.RE.PCRE.RE: edMS :: QuasiQuoter
+ Text.RE.PCRE.RE: edMultilineInsensitive :: QuasiQuoter
+ Text.RE.PCRE.RE: edMultilineSensitive :: QuasiQuoter
+ Text.RE.PCRE.RE: ed_ :: QuasiQuoter
+ Text.RE.PCRE.RE: escapeWith :: (Functor m, Monad m) => SimpleREOptions -> (String -> String) -> String -> m RE
+ Text.RE.PCRE.RE: escapeWithOptions :: (IsOption o RE CompOption ExecOption, Functor m, Monad m) => o -> (String -> String) -> String -> m RE
+ Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption () Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption (Text.RE.Types.REOptions.Macros Text.RE.PCRE.RE.RE) Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption Text.RE.PCRE.RE.REOptions Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption Text.RE.Types.REOptions.SimpleREOptions Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption Text.Regex.PCRE.Wrap.CompOption Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.PCRE.RE: instance Text.RE.Types.REOptions.IsOption Text.Regex.PCRE.Wrap.ExecOption Text.RE.PCRE.RE.RE Text.Regex.PCRE.Wrap.CompOption Text.Regex.PCRE.Wrap.ExecOption
+ Text.RE.PCRE.RE: noPreludeREOptions :: REOptions
+ Text.RE.PCRE.RE: type REOptions = REOptions_ RE CompOption ExecOption
+ Text.RE.PCRE.RE: unpackSimpleREOptions :: SimpleREOptions -> REOptions
+ Text.RE.PCRE.Sequence: (*=~/) :: (Seq Char) -> SearchReplace RE (Seq Char) -> (Seq Char)
+ Text.RE.PCRE.Sequence: (?=~/) :: (Seq Char) -> SearchReplace RE (Seq Char) -> (Seq Char)
+ Text.RE.PCRE.Sequence: BlockInsensitive :: SimpleREOptions
+ Text.RE.PCRE.Sequence: BlockSensitive :: SimpleREOptions
+ Text.RE.PCRE.Sequence: MultilineInsensitive :: SimpleREOptions
+ Text.RE.PCRE.Sequence: MultilineSensitive :: SimpleREOptions
+ Text.RE.PCRE.Sequence: allMatches :: Matches a -> [Match a]
+ Text.RE.PCRE.Sequence: anyMatches :: Matches a -> Bool
+ Text.RE.PCRE.Sequence: countMatches :: Matches a -> Int
+ Text.RE.PCRE.Sequence: data Match a :: * -> *
+ Text.RE.PCRE.Sequence: data Matches a :: * -> *
+ Text.RE.PCRE.Sequence: data SimpleREOptions :: *
+ Text.RE.PCRE.Sequence: escapeWith :: (Functor m, Monad m) => SimpleREOptions -> (String -> String) -> String -> m RE
+ Text.RE.PCRE.Sequence: matchSource :: Match a -> a
+ Text.RE.PCRE.Sequence: matched :: Match a -> Bool
+ Text.RE.PCRE.Sequence: matchedText :: Match a -> Maybe a
+ Text.RE.PCRE.Sequence: matches :: Matches a -> [a]
+ Text.RE.PCRE.Sequence: matchesSource :: Matches a -> a
+ Text.RE.PCRE.String: (*=~/) :: String -> SearchReplace RE String -> String
+ Text.RE.PCRE.String: (?=~/) :: String -> SearchReplace RE String -> String
+ Text.RE.PCRE.String: BlockInsensitive :: SimpleREOptions
+ Text.RE.PCRE.String: BlockSensitive :: SimpleREOptions
+ Text.RE.PCRE.String: MultilineInsensitive :: SimpleREOptions
+ Text.RE.PCRE.String: MultilineSensitive :: SimpleREOptions
+ Text.RE.PCRE.String: allMatches :: Matches a -> [Match a]
+ Text.RE.PCRE.String: anyMatches :: Matches a -> Bool
+ Text.RE.PCRE.String: countMatches :: Matches a -> Int
+ Text.RE.PCRE.String: data Match a :: * -> *
+ Text.RE.PCRE.String: data Matches a :: * -> *
+ Text.RE.PCRE.String: data SimpleREOptions :: *
+ Text.RE.PCRE.String: escapeWith :: (Functor m, Monad m) => SimpleREOptions -> (String -> String) -> String -> m RE
+ Text.RE.PCRE.String: matchSource :: Match a -> a
+ Text.RE.PCRE.String: matched :: Match a -> Bool
+ Text.RE.PCRE.String: matchedText :: Match a -> Maybe a
+ Text.RE.PCRE.String: matches :: Matches a -> [a]
+ Text.RE.PCRE.String: matchesSource :: Matches a -> a
- Text.RE.PCRE.ByteString: compileRegexWith :: (Functor m, Monad m) => SimpleRegexOptions -> String -> m RE
+ Text.RE.PCRE.ByteString: compileRegexWith :: (Functor m, Monad m) => SimpleREOptions -> String -> m RE
- Text.RE.PCRE.ByteString: escape :: (String -> String) -> String -> RE
+ Text.RE.PCRE.ByteString: escape :: (Functor m, Monad m) => (String -> String) -> String -> m RE
- Text.RE.PCRE.ByteString.Lazy: compileRegexWith :: (Functor m, Monad m) => SimpleRegexOptions -> String -> m RE
+ Text.RE.PCRE.ByteString.Lazy: compileRegexWith :: (Functor m, Monad m) => SimpleREOptions -> String -> m RE
- Text.RE.PCRE.ByteString.Lazy: escape :: (String -> String) -> String -> RE
+ Text.RE.PCRE.ByteString.Lazy: escape :: (Functor m, Monad m) => (String -> String) -> String -> m RE
- Text.RE.PCRE.RE: compileRegexWith :: (Functor m, Monad m) => SimpleRegexOptions -> String -> m RE
+ Text.RE.PCRE.RE: compileRegexWith :: (Functor m, Monad m) => SimpleREOptions -> String -> m RE
- Text.RE.PCRE.RE: escape :: (String -> String) -> String -> RE
+ Text.RE.PCRE.RE: escape :: (Functor m, Monad m) => (String -> String) -> String -> m RE
- Text.RE.PCRE.RE: reOptions :: RE -> Options
+ Text.RE.PCRE.RE: reOptions :: RE -> REOptions
- Text.RE.PCRE.Sequence: compileRegexWith :: (Functor m, Monad m) => SimpleRegexOptions -> String -> m RE
+ Text.RE.PCRE.Sequence: compileRegexWith :: (Functor m, Monad m) => SimpleREOptions -> String -> m RE
- Text.RE.PCRE.Sequence: escape :: (String -> String) -> String -> RE
+ Text.RE.PCRE.Sequence: escape :: (Functor m, Monad m) => (String -> String) -> String -> m RE
- Text.RE.PCRE.String: compileRegexWith :: (Functor m, Monad m) => SimpleRegexOptions -> String -> m RE
+ Text.RE.PCRE.String: compileRegexWith :: (Functor m, Monad m) => SimpleREOptions -> String -> m RE
- Text.RE.PCRE.String: escape :: (String -> String) -> String -> RE
+ Text.RE.PCRE.String: escape :: (Functor m, Monad m) => (String -> String) -> String -> m RE
Files
- README.markdown +3/−5
- Text/RE/PCRE.hs +40/−22
- Text/RE/PCRE/ByteString.hs +38/−25
- Text/RE/PCRE/ByteString/Lazy.hs +38/−25
- Text/RE/PCRE/RE.hs +326/−121
- Text/RE/PCRE/Sequence.hs +38/−25
- Text/RE/PCRE/String.hs +38/−25
- changelog +11/−0
- regex-with-pcre.cabal +30/−4
README.markdown view
@@ -62,7 +62,7 @@ ☒ 2017-03-16 v0.8.0.0 [Tidy up the API](https://github.com/iconnect/regex/milestone/10) - ☐ 2017-03-18 v0.9.0.0 [Add type-safe replacement templates and use TemplateHaskellQuotes](https://github.com/iconnect/regex/milestone/9)+ ☒ 2017-03-18 v0.9.0.0 [Finish tidying up the API, Add type-safe replacement templates and exploit TemplateHaskellQuotes](https://github.com/iconnect/regex/milestone/9) ☐ 2017-03-31 v1.0.0.0 [First stable release](https://github.com/iconnect/regex/milestone/3) @@ -103,10 +103,8 @@ If you have any feedback or suggestion then please drop us a line. - `t` [@hregex](https://twitter.com/hregex)-- `e` maintainers@regex.uk-+ `t` [@hregex](https://twitter.com/hregex)\n+ `e` maintainers@regex.uk\n `w` http://issues.regex.uk The [Contact page](http://contact.regex.uk) has more details.
Text/RE/PCRE.hs view
@@ -1,5 +1,6 @@-{-# LANGUAGE FlexibleContexts #-}-{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleContexts #-}+{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -fno-warn-duplicate-exports #-} #if __GLASGOW_HASKELL__ >= 800 {-# OPTIONS_GHC -fno-warn-redundant-constraints #-} #endif@@ -9,17 +10,36 @@ ( -- * Tutorial -- $tutorial-- -- * The Overloaded Match Operators+ --+ -- * The Match Operators (*=~) , (?=~)+ -- * The SearchReplace Operators+ , (*=~/)+ , (?=~/)+ -- * The Classic rexex-base Match Operators , (=~) , (=~~)- -- * The Toolkit- -- $toolkit- , module Text.RE- -- * The 'RE' Type- -- $re+ -- * Matches+ , Matches+ , matchesSource+ , allMatches+ , anyMatches+ , countMatches+ , matches+ -- * Match+ , Match+ , matchSource+ , matched+ , matchedText+ -- * The 'RE' Type and Functions+ , RE+ , SimpleREOptions(..)+ , reSource+ , compileRegex+ , compileRegexWith+ , escape+ , escapeWith , module Text.RE.PCRE.RE -- * The Operator Instances -- $instances@@ -40,7 +60,9 @@ import Text.RE.PCRE.ByteString.Lazy() import Text.RE.PCRE.Sequence() import Text.RE.PCRE.String()+import Text.RE.SearchReplace import Text.RE.Types.IsRegex+import Text.RE.Types.REOptions -- | find all matches in text@@ -57,6 +79,14 @@ -> Match s (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ matchOnce rex bs +-- | search and replace once+(?=~/) :: IsRegex RE s => s -> SearchReplace RE s -> s+(?=~/) = flip searchReplaceFirst++-- | search and replace, all occurrences+(*=~/) :: IsRegex RE s => s -> SearchReplace RE s -> s+(*=~/) = flip searchReplaceAll+ -- | the regex-base polymorphic match operator (=~) :: ( B.RegexContext PCRE.Regex s a , B.RegexMaker PCRE.Regex PCRE.CompOption PCRE.ExecOption s@@ -77,19 +107,7 @@ (=~~) bs rex = B.matchM (reRegex rex) bs -- $tutorial--- We have a regex tutorial at <http://tutorial.regex.uk>. These API--- docs are mainly for reference.---- $toolkit------ Beyond the above match operators and the regular expression type--- below, "Text.RE" contains the toolkit for replacing captures,--- specifying options, etc.---- $re------ "Text.RE.PCRE.RE" contains the toolkit specific to the 'RE' type,--- the type generated by the gegex compiler.+-- We have a regex tutorial at <http://tutorial.regex.uk>. -- $instances --
Text/RE/PCRE/ByteString.hs view
@@ -13,22 +13,36 @@ ( -- * Tutorial -- $tutorial-+ -- -- * The Match Operators (*=~) , (?=~)+ -- * The SearchReplace Operators+ , (*=~/)+ , (?=~/)+ -- * The Classic rexex-base Match Operators , (=~) , (=~~)- -- * The Toolkit- -- $toolkit- , module Text.RE- -- * The 'RE' Type and functions- -- $re+ -- * Matches+ , Matches+ , matchesSource+ , allMatches+ , anyMatches+ , countMatches+ , matches+ -- * Match+ , Match+ , matchSource+ , matched+ , matchedText+ -- * The 'RE' Type and Functions , RE+ , SimpleREOptions(..) , reSource , compileRegex , compileRegexWith , escape+ , escapeWith , module Text.RE.PCRE.RE ) where @@ -37,8 +51,11 @@ import Data.Typeable import Text.Regex.Base import Text.RE-import Text.RE.Types.IsRegex import Text.RE.Internal.AddCaptureNames+import Text.RE.SearchReplace+import Text.RE.Types.IsRegex+import Text.RE.Types.REOptions+import Text.RE.Types.Replace import Text.RE.PCRE.RE import qualified Text.Regex.PCRE as PCRE @@ -55,6 +72,14 @@ -> Match B.ByteString (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs +-- | search and replace once+(?=~/) :: B.ByteString -> SearchReplace RE B.ByteString -> B.ByteString+(?=~/) = flip searchReplaceFirst++-- | search and replace, all occurrences+(*=~/) :: B.ByteString -> SearchReplace RE B.ByteString -> B.ByteString+(*=~/) = flip searchReplaceAll+ -- | the regex-base polymorphic match operator (=~) :: ( Typeable a , RegexContext PCRE.Regex B.ByteString a@@ -78,23 +103,11 @@ (=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE B.ByteString where- matchOnce = flip (?=~)- matchMany = flip (*=~)- makeRegexWith = \o -> compileRegexWith o . unpackE- makeRegex = compileRegex . unpackE- regexSource = packE . reSource+ matchOnce = flip (?=~)+ matchMany = flip (*=~)+ makeRegexWith = \o -> compileRegexWith o . unpackR+ makeSearchReplaceWith = \o r t -> compileSearchReplaceWith o (unpackR r) (unpackR t)+ regexSource = packR . reSource -- $tutorial--- We have a regex tutorial at <http://tutorial.regex.uk>. These API--- docs are mainly for reference.---- $toolkit------ Beyond the above match operators and the regular expression type--- below, "Text.RE" contains the toolkit for replacing captures,--- specifying options, etc.---- $re------ "Text.RE.PCRE.RE" contains the toolkit specific to the 'RE' type,--- the type generated by the gegex compiler.+-- We have a regex tutorial at <http://tutorial.regex.uk>.
Text/RE/PCRE/ByteString/Lazy.hs view
@@ -13,22 +13,36 @@ ( -- * Tutorial -- $tutorial-+ -- -- * The Match Operators (*=~) , (?=~)+ -- * The SearchReplace Operators+ , (*=~/)+ , (?=~/)+ -- * The Classic rexex-base Match Operators , (=~) , (=~~)- -- * The Toolkit- -- $toolkit- , module Text.RE- -- * The 'RE' Type and functions- -- $re+ -- * Matches+ , Matches+ , matchesSource+ , allMatches+ , anyMatches+ , countMatches+ , matches+ -- * Match+ , Match+ , matchSource+ , matched+ , matchedText+ -- * The 'RE' Type and Functions , RE+ , SimpleREOptions(..) , reSource , compileRegex , compileRegexWith , escape+ , escapeWith , module Text.RE.PCRE.RE ) where @@ -37,8 +51,11 @@ import Data.Typeable import Text.Regex.Base import Text.RE-import Text.RE.Types.IsRegex import Text.RE.Internal.AddCaptureNames+import Text.RE.SearchReplace+import Text.RE.Types.IsRegex+import Text.RE.Types.REOptions+import Text.RE.Types.Replace import Text.RE.PCRE.RE import qualified Text.Regex.PCRE as PCRE @@ -55,6 +72,14 @@ -> Match LBS.ByteString (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs +-- | search and replace once+(?=~/) :: LBS.ByteString -> SearchReplace RE LBS.ByteString -> LBS.ByteString+(?=~/) = flip searchReplaceFirst++-- | search and replace, all occurrences+(*=~/) :: LBS.ByteString -> SearchReplace RE LBS.ByteString -> LBS.ByteString+(*=~/) = flip searchReplaceAll+ -- | the regex-base polymorphic match operator (=~) :: ( Typeable a , RegexContext PCRE.Regex LBS.ByteString a@@ -78,23 +103,11 @@ (=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE LBS.ByteString where- matchOnce = flip (?=~)- matchMany = flip (*=~)- makeRegexWith = \o -> compileRegexWith o . unpackE- makeRegex = compileRegex . unpackE- regexSource = packE . reSource+ matchOnce = flip (?=~)+ matchMany = flip (*=~)+ makeRegexWith = \o -> compileRegexWith o . unpackR+ makeSearchReplaceWith = \o r t -> compileSearchReplaceWith o (unpackR r) (unpackR t)+ regexSource = packR . reSource -- $tutorial--- We have a regex tutorial at <http://tutorial.regex.uk>. These API--- docs are mainly for reference.---- $toolkit------ Beyond the above match operators and the regular expression type--- below, "Text.RE" contains the toolkit for replacing captures,--- specifying options, etc.---- $re------ "Text.RE.PCRE.RE" contains the toolkit specific to the 'RE' type,--- the type generated by the gegex compiler.+-- We have a regex tutorial at <http://tutorial.regex.uk>.
Text/RE/PCRE/RE.hs view
@@ -1,7 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE RecordWildCards #-}-{-# LANGUAGE QuasiQuotes #-}-{-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE FlexibleInstances #-}@@ -9,28 +7,39 @@ {-# LANGUAGE CPP #-} #if __GLASGOW_HASKELL__ >= 800 {-# OPTIONS_GHC -fno-warn-redundant-constraints #-}+{-# LANGUAGE TemplateHaskellQuotes #-}+#else+{-# LANGUAGE QuasiQuotes #-}+{-# LANGUAGE TemplateHaskell #-} #endif {-# OPTIONS_GHC -fno-warn-orphans #-} module Text.RE.PCRE.RE- ( re- , reMS- , reMI- , reBS- , reBI- , reMultilineSensitive- , reMultilineInsensitive- , reBlockSensitive- , reBlockInsensitive- , re_- , cp+ ( -- * RE Type+ RE , regexType- , RE , reOptions , reSource , reCaptureNames , reRegex- , Options+ -- * REOptions Type+ , REOptions+ , defaultREOptions+ , noPreludeREOptions+ -- * Compiling Regular Expressions+ , compileRegex+ , compileRegexWith+ , compileRegexWithOptions+ -- * Compiling Search-Replace Templates+ , compileSearchReplace+ , compileSearchReplaceWith+ , compileSearchReplaceWithREOptions+ -- * Escaping String+ , escape+ , escapeWith+ , escapeWithOptions+ , escapeREString+ -- * Macros Standard Environment , prelude , preludeEnv , preludeTestsFailing@@ -38,14 +47,29 @@ , preludeSummary , preludeSources , preludeSource- , noPreludeOptions- , defaultOptions- , unpackSimpleRegexOptions- , compileRegex- , compileRegexWith- , compileRegexWithOptions- , escape- , escapeREString+ , unpackSimpleREOptions+ -- * The Quasi Quoters+ , re+ , reMS+ , reMI+ , reBS+ , reBI+ , reMultilineSensitive+ , reMultilineInsensitive+ , reBlockSensitive+ , reBlockInsensitive+ , re_+ , ed+ , edMS+ , edMI+ , edBS+ , edBI+ , edMultilineSensitive+ , edMultilineInsensitive+ , edBlockSensitive+ , edBlockInsensitive+ , ed_+ , cp ) where import Data.Bits@@ -53,98 +77,92 @@ import Language.Haskell.TH import Language.Haskell.TH.Quote import Prelude.Compat-import Text.RE import Text.RE.Internal.EscapeREString import Text.RE.Internal.NamedCaptures import Text.RE.Internal.PreludeMacros import Text.RE.Internal.QQ+import Text.RE.SearchReplace import Text.RE.TestBench import Text.RE.Types.CaptureID-import Text.RE.Types.Options+import Text.RE.Types.IsRegex+import Text.RE.Types.REOptions+import Text.RE.Types.Replace import Text.Regex.PCRE -re- , reMS- , reMI- , reBS- , reBI- , reMultilineSensitive- , reMultilineInsensitive- , reBlockSensitive- , reBlockInsensitive- , re_ :: QuasiQuoter--re = re' $ Just minBound-reMS = reMultilineSensitive-reMI = reMultilineInsensitive-reBS = reBlockSensitive-reBI = reBlockInsensitive-reMultilineSensitive = re' $ Just MultilineSensitive-reMultilineInsensitive = re' $ Just MultilineInsensitive-reBlockSensitive = re' $ Just BlockSensitive-reBlockInsensitive = re' $ Just BlockInsensitive-re_ = re' Nothing--regexType :: RegexType-regexType =- mkPCRE $ \txt env md -> txt =~ mdRegexSource regexType ExclCaptures env md-+-- | the RE type for this back end representing a well-formed, compiled+-- RE data RE = RE- { _re_options :: !Options+ { _re_options :: !REOptions , _re_source :: !String , _re_cnames :: !CaptureNames , _re_regex :: !Regex } -reOptions :: RE -> Options+-- | some functions in the "Text.RE.TestBench" need the back end to+-- be passed dynamically as a 'RegexType' parameters: use 'regexType'+-- fpr this backend+regexType :: RegexType+regexType =+ mkPCRE $ \txt env md -> txt =~ mdRegexSource regexType ExclCaptures env md++-- | extract the 'REOptions' from the @RE@+reOptions :: RE -> REOptions reOptions = _re_options +-- | extract the RE source string from the @RE@ reSource :: RE -> String reSource = _re_source +-- | extract the 'CaptureNames' from the @RE@ reCaptureNames :: RE -> CaptureNames reCaptureNames = _re_cnames +-- | extract the back end compiled 'Regex' type from the @RE@ reRegex :: RE -> Regex reRegex = _re_regex -type Options = Options_ RE CompOption ExecOption -instance IsOption SimpleRegexOptions RE CompOption ExecOption where- makeOptions = unpackSimpleRegexOptions+------------------------------------------------------------------------+-- REOptions+------------------------------------------------------------------------ +-- | and the REOptions for this back end (see "Text.RE.Types.REOptions"+-- for details)+type REOptions = REOptions_ RE CompOption ExecOption++instance IsOption SimpleREOptions RE CompOption ExecOption where+ makeREOptions = unpackSimpleREOptions+ instance IsOption (Macros RE) RE CompOption ExecOption where- makeOptions ms = Options ms def_comp_option def_exec_option+ makeREOptions ms = REOptions ms def_comp_option def_exec_option instance IsOption CompOption RE CompOption ExecOption where- makeOptions co = Options prelude co def_exec_option+ makeREOptions co = REOptions prelude co def_exec_option instance IsOption ExecOption RE CompOption ExecOption where- makeOptions eo = Options prelude def_comp_option eo+ makeREOptions eo = REOptions prelude def_comp_option eo -instance IsOption Options RE CompOption ExecOption where- makeOptions = id+instance IsOption REOptions RE CompOption ExecOption where+ makeREOptions = id instance IsOption () RE CompOption ExecOption where- makeOptions _ = unpackSimpleRegexOptions minBound--def_comp_option :: CompOption-def_comp_option = optionsComp defaultOptions--def_exec_option :: ExecOption-def_exec_option = optionsExec defaultOptions+ makeREOptions _ = unpackSimpleREOptions minBound -noPreludeOptions :: Options-noPreludeOptions = defaultOptions { optionsMacs = emptyMacros }+-- | the default 'REOptions'+defaultREOptions :: REOptions+defaultREOptions = makeREOptions (minBound::SimpleREOptions) -defaultOptions :: Options-defaultOptions = makeOptions (minBound::SimpleRegexOptions)+-- | the default 'REOptions' but with no RE macros defined+noPreludeREOptions :: REOptions+noPreludeREOptions = defaultREOptions { optionsMacs = emptyMacros } -unpackSimpleRegexOptions :: SimpleRegexOptions -> Options-unpackSimpleRegexOptions sro =- Options+-- | convert a universal 'SimpleReOptions' into the 'REOptions' used+-- by this back end+unpackSimpleREOptions :: SimpleREOptions -> REOptions+unpackSimpleREOptions sro =+ REOptions { optionsMacs = prelude , optionsComp = comp , optionsExec = defaultExecOpt@@ -164,15 +182,23 @@ BlockSensitive -> (,) False False BlockInsensitive -> (,) False True --- | compie a RE from a string using default options++------------------------------------------------------------------------+-- Compiling Regular Expressions+------------------------------------------------------------------------++-- | compile a 'String' into a 'RE' with the default options,+-- generating an error if the RE is not well formed compileRegex :: (Functor m,Monad m) => String -> m RE compileRegex = compileRegexWithOptions () --- | compie a RE from a @String@ and 'SimpleRegexOptions'-compileRegexWith :: (Functor m,Monad m) => SimpleRegexOptions -> String -> m RE+-- | compile a 'String' into a 'RE' using the given @SimpleREOptions@,+-- generating an error if the RE is not well formed+compileRegexWith :: (Functor m,Monad m) => SimpleREOptions -> String -> m RE compileRegexWith = compileRegexWithOptions --- | compile a RE from a @String@ and a complete set of 'Options'+-- | compile a 'String' into a 'RE' using the given @SimpleREOptions@,+-- generating an error if the RE is not well formed compileRegexWithOptions :: ( IsOption o RE CompOption ExecOption , Functor m , Monad m@@ -180,86 +206,265 @@ => o -> String -> m RE-compileRegexWithOptions = compileRegex_ . makeOptions+compileRegexWithOptions = compileRegex_ . makeREOptions -compileRegex_ :: ( Functor m , Monad m )- => Options- -> String- -> m RE-compileRegex_ os re_s = uncurry mk <$> compileRegex' os re_s++------------------------------------------------------------------------+-- Compiling Search Replace Templates+------------------------------------------------------------------------++-- | compile a SearchReplace template generating errors if the RE or+-- the template are not well formed -- all capture references being checked+compileSearchReplace :: (Monad m,Functor m,IsRegex RE s)+ => String+ -> String+ -> m (SearchReplace RE s)+compileSearchReplace = compileSearchReplaceWith minBound++-- | compile a SearchReplace template, with simple options, generating+-- errors if the RE or the template are not well formed -- all capture+-- references being checked+compileSearchReplaceWith :: (Monad m,Functor m,IsRegex RE s)+ => SimpleREOptions+ -> String+ -> String+ -> m (SearchReplace RE s)+compileSearchReplaceWith sro = compileSearchAndReplace_ packR $ compileRegexWith sro++-- | compile a SearchReplace template, with general options, generating+-- errors if the RE or the template are not well formed -- all capture+-- references being checked+compileSearchReplaceWithREOptions :: (Monad m,Functor m,IsRegex RE s)+ => REOptions+ -> String+ -> String+ -> m (SearchReplace RE s)+compileSearchReplaceWithREOptions os = compileSearchAndReplace_ packR $ compileRegexWithOptions os+++------------------------------------------------------------------------+-- Escaping Strings+------------------------------------------------------------------------++-- | convert a string into a RE that matches that string, and apply it+-- to an argument continuation function to make up the RE string to be+-- compiled+escape :: (Functor m,Monad m)+ => (String->String)+ -> String+ -> m RE+escape = escapeWith minBound++-- | convert a string into a RE that matches that string, and apply it+-- to an argument continuation function to make up the RE string to be+-- compiled with the default options+escapeWith :: (Functor m,Monad m)+ => SimpleREOptions+ -> (String->String)+ -> String+ -> m RE+escapeWith = escapeWithOptions++-- | convert a string into a RE that matches that string, and apply it+-- to an argument continuation function to make up the RE string to be+-- compiled the given options+escapeWithOptions :: ( IsOption o RE CompOption ExecOption+ , Functor m+ , Monad m+ )+ => o+ -> (String->String)+ -> String+ -> m RE+escapeWithOptions o f = compileRegexWithOptions o . f . escapeREString+++------------------------------------------------------------------------+-- Macro Standard Environment+------------------------------------------------------------------------++prelude :: Macros RE+prelude = runIdentity $ preludeMacros mk regexType ExclCaptures where- mk cnms rex =- RE- { _re_options = os- , _re_source = re_s- , _re_cnames = cnms- , _re_regex = rex- }+ mk = Identity . unsafeCompileRegex_ noPreludeREOptions -re' :: Maybe SimpleRegexOptions -> QuasiQuoter+preludeTestsFailing :: [MacroID]+preludeTestsFailing = badMacros preludeEnv++preludeEnv :: MacroEnv+preludeEnv = preludeMacroEnv regexType++preludeTable :: String+preludeTable = preludeMacroTable regexType++preludeSummary :: PreludeMacro -> String+preludeSummary = preludeMacroSummary regexType++preludeSources :: String+preludeSources = preludeMacroSources regexType++preludeSource :: PreludeMacro -> String+preludeSource = preludeMacroSource regexType+++------------------------------------------------------------------------+-- Quasi Quoters+------------------------------------------------------------------------++-- | the @[re| ... |]@ and @[ed| ... /// ... |]@ quasi quoters+re+ , reMS+ , reMI+ , reBS+ , reBI+ , reMultilineSensitive+ , reMultilineInsensitive+ , reBlockSensitive+ , reBlockInsensitive+ , re_+ , ed+ , edMS+ , edMI+ , edBS+ , edBI+ , edMultilineSensitive+ , edMultilineInsensitive+ , edBlockSensitive+ , edBlockInsensitive+ , ed_ :: QuasiQuoter++re = re' $ Just minBound+reMS = reMultilineSensitive+reMI = reMultilineInsensitive+reBS = reBlockSensitive+reBI = reBlockInsensitive+reMultilineSensitive = re' $ Just MultilineSensitive+reMultilineInsensitive = re' $ Just MultilineInsensitive+reBlockSensitive = re' $ Just BlockSensitive+reBlockInsensitive = re' $ Just BlockInsensitive+re_ = re' Nothing++ed = ed' $ Just minBound+edMS = edMultilineSensitive+edMI = edMultilineInsensitive+edBS = edBlockSensitive+edBI = edBlockInsensitive+edMultilineSensitive = ed' $ Just MultilineSensitive+edMultilineInsensitive = ed' $ Just MultilineInsensitive+edBlockSensitive = ed' $ Just BlockSensitive+edBlockInsensitive = ed' $ Just BlockInsensitive+ed_ = ed' Nothing+++------------------------------------------------------------------------+-- re Helpers+------------------------------------------------------------------------++re' :: Maybe SimpleREOptions -> QuasiQuoter re' mb = case mb of Nothing ->- (qq0 "re_")+ (qq0 "re'") { quoteExp = parse minBound (\rs->[|flip unsafeCompileRegex rs|]) } Just sro ->- (qq0 "re")+ (qq0 "re'") { quoteExp = parse sro (\rs->[|unsafeCompileRegexSimple sro rs|]) } where- parse :: SimpleRegexOptions -> (String->Q Exp) -> String -> Q Exp+ parse :: SimpleREOptions -> (String->Q Exp) -> String -> Q Exp parse sro mk rs = either error (\_->mk rs) $ compileRegex_ os rs where- os = unpackSimpleRegexOptions sro+ os = unpackSimpleREOptions sro -unsafeCompileRegexSimple :: SimpleRegexOptions -> String -> RE+unsafeCompileRegexSimple :: SimpleREOptions -> String -> RE unsafeCompileRegexSimple sro re_s = unsafeCompileRegex os re_s where- os = unpackSimpleRegexOptions sro+ os = unpackSimpleREOptions sro unsafeCompileRegex :: IsOption o RE CompOption ExecOption => o -> String -> RE-unsafeCompileRegex = unsafeCompileRegex_ . makeOptions+unsafeCompileRegex = unsafeCompileRegex_ . makeREOptions -unsafeCompileRegex_ :: Options -> String -> RE+unsafeCompileRegex_ :: REOptions -> String -> RE unsafeCompileRegex_ os = either oops id . compileRegexWithOptions os where oops = error . ("unsafeCompileRegex: " ++) compileRegex' :: (Functor m,Monad m)- => Options+ => REOptions -> String -> m (CaptureNames,Regex)-compileRegex' Options{..} s0 = do- (cnms,s2) <- either fail return $ extractNamedCaptures s1+compileRegex' REOptions{..} s0 = do+ ((_,cnms),s2) <- either fail return $ extractNamedCaptures s1 (,) cnms <$> makeRegexOptsM optionsComp optionsExec s2 where s1 = expandMacros reSource optionsMacs s0 -prelude :: Macros RE-prelude = runIdentity $ preludeMacros mk regexType ExclCaptures+compileRegex_ :: ( Functor m , Monad m )+ => REOptions+ -> String+ -> m RE+compileRegex_ os re_s = uncurry mk <$> compileRegex' os re_s where- mk = Identity . unsafeCompileRegex_ noPreludeOptions+ mk cnms rex =+ RE+ { _re_options = os+ , _re_source = re_s+ , _re_cnames = cnms+ , _re_regex = rex+ } -preludeTestsFailing :: [MacroID]-preludeTestsFailing = badMacros preludeEnv -preludeEnv :: MacroEnv-preludeEnv = preludeMacroEnv regexType+------------------------------------------------------------------------+-- ed Helpers+------------------------------------------------------------------------ -preludeTable :: String-preludeTable = preludeMacroTable regexType+ed' :: Maybe SimpleREOptions -> QuasiQuoter+ed' mb = case mb of+ Nothing ->+ (qq0 "ed'")+ { quoteExp = parse minBound (\rs->[|flip unsafe_compile_sr rs|])+ }+ Just sro ->+ (qq0 "ed'")+ { quoteExp = parse sro (\rs->[|unsafe_compile_sr_simple sro rs|])+ }+ where+ parse :: SimpleREOptions -> (String->Q Exp) -> String -> Q Exp+ parse sro mk ts = either error (\_->mk ts) ei+ where+ ei :: Either String (SearchReplace RE String)+ ei = compileSearchReplace_ id (compileRegexWith sro) ts -preludeSummary :: PreludeMacro -> String-preludeSummary = preludeMacroSummary regexType+unsafe_compile_sr_simple :: IsRegex RE s+ => SimpleREOptions+ -> String+ -> SearchReplace RE s+unsafe_compile_sr_simple sro =+ unsafe_compile_sr $ unpackSimpleREOptions sro -preludeSources :: String-preludeSources = preludeMacroSources regexType+unsafe_compile_sr :: ( IsOption o RE CompOption ExecOption+ , IsRegex RE s+ )+ => o+ -> String+ -> SearchReplace RE s+unsafe_compile_sr os =+ unsafeCompileSearchReplace_ packR $ compileRegexWithOptions os -preludeSource :: PreludeMacro -> String-preludeSource = preludeMacroSource regexType -escape :: (String->String) -> String -> RE-escape f = unsafeCompileRegex () . f . escapeREString+++++++++def_comp_option :: CompOption+def_comp_option = optionsComp defaultREOptions++def_exec_option :: ExecOption+def_exec_option = optionsExec defaultREOptions
Text/RE/PCRE/Sequence.hs view
@@ -13,22 +13,36 @@ ( -- * Tutorial -- $tutorial-+ -- -- * The Match Operators (*=~) , (?=~)+ -- * The SearchReplace Operators+ , (*=~/)+ , (?=~/)+ -- * The Classic rexex-base Match Operators , (=~) , (=~~)- -- * The Toolkit- -- $toolkit- , module Text.RE- -- * The 'RE' Type and functions- -- $re+ -- * Matches+ , Matches+ , matchesSource+ , allMatches+ , anyMatches+ , countMatches+ , matches+ -- * Match+ , Match+ , matchSource+ , matched+ , matchedText+ -- * The 'RE' Type and Functions , RE+ , SimpleREOptions(..) , reSource , compileRegex , compileRegexWith , escape+ , escapeWith , module Text.RE.PCRE.RE ) where @@ -37,8 +51,11 @@ import Data.Typeable import Text.Regex.Base import Text.RE-import Text.RE.Types.IsRegex import Text.RE.Internal.AddCaptureNames+import Text.RE.SearchReplace+import Text.RE.Types.IsRegex+import Text.RE.Types.REOptions+import Text.RE.Types.Replace import Text.RE.PCRE.RE import qualified Text.Regex.PCRE as PCRE @@ -55,6 +72,14 @@ -> Match (S.Seq Char) (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs +-- | search and replace once+(?=~/) :: (S.Seq Char) -> SearchReplace RE (S.Seq Char) -> (S.Seq Char)+(?=~/) = flip searchReplaceFirst++-- | search and replace, all occurrences+(*=~/) :: (S.Seq Char) -> SearchReplace RE (S.Seq Char) -> (S.Seq Char)+(*=~/) = flip searchReplaceAll+ -- | the regex-base polymorphic match operator (=~) :: ( Typeable a , RegexContext PCRE.Regex (S.Seq Char) a@@ -78,23 +103,11 @@ (=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE (S.Seq Char) where- matchOnce = flip (?=~)- matchMany = flip (*=~)- makeRegexWith = \o -> compileRegexWith o . unpackE- makeRegex = compileRegex . unpackE- regexSource = packE . reSource+ matchOnce = flip (?=~)+ matchMany = flip (*=~)+ makeRegexWith = \o -> compileRegexWith o . unpackR+ makeSearchReplaceWith = \o r t -> compileSearchReplaceWith o (unpackR r) (unpackR t)+ regexSource = packR . reSource -- $tutorial--- We have a regex tutorial at <http://tutorial.regex.uk>. These API--- docs are mainly for reference.---- $toolkit------ Beyond the above match operators and the regular expression type--- below, "Text.RE" contains the toolkit for replacing captures,--- specifying options, etc.---- $re------ "Text.RE.PCRE.RE" contains the toolkit specific to the 'RE' type,--- the type generated by the gegex compiler.+-- We have a regex tutorial at <http://tutorial.regex.uk>.
Text/RE/PCRE/String.hs view
@@ -13,22 +13,36 @@ ( -- * Tutorial -- $tutorial-+ -- -- * The Match Operators (*=~) , (?=~)+ -- * The SearchReplace Operators+ , (*=~/)+ , (?=~/)+ -- * The Classic rexex-base Match Operators , (=~) , (=~~)- -- * The Toolkit- -- $toolkit- , module Text.RE- -- * The 'RE' Type and functions- -- $re+ -- * Matches+ , Matches+ , matchesSource+ , allMatches+ , anyMatches+ , countMatches+ , matches+ -- * Match+ , Match+ , matchSource+ , matched+ , matchedText+ -- * The 'RE' Type and Functions , RE+ , SimpleREOptions(..) , reSource , compileRegex , compileRegexWith , escape+ , escapeWith , module Text.RE.PCRE.RE ) where @@ -37,8 +51,11 @@ import Data.Typeable import Text.Regex.Base import Text.RE-import Text.RE.Types.IsRegex import Text.RE.Internal.AddCaptureNames+import Text.RE.SearchReplace+import Text.RE.Types.IsRegex+import Text.RE.Types.REOptions+import Text.RE.Types.Replace import Text.RE.PCRE.RE import qualified Text.Regex.PCRE as PCRE @@ -55,6 +72,14 @@ -> Match String (?=~) bs rex = addCaptureNamesToMatch (reCaptureNames rex) $ match (reRegex rex) bs +-- | search and replace once+(?=~/) :: String -> SearchReplace RE String -> String+(?=~/) = flip searchReplaceFirst++-- | search and replace, all occurrences+(*=~/) :: String -> SearchReplace RE String -> String+(*=~/) = flip searchReplaceAll+ -- | the regex-base polymorphic match operator (=~) :: ( Typeable a , RegexContext PCRE.Regex String a@@ -78,23 +103,11 @@ (=~~) bs rex = addCaptureNames (reCaptureNames rex) <$> matchM (reRegex rex) bs instance IsRegex RE String where- matchOnce = flip (?=~)- matchMany = flip (*=~)- makeRegexWith = \o -> compileRegexWith o . unpackE- makeRegex = compileRegex . unpackE- regexSource = packE . reSource+ matchOnce = flip (?=~)+ matchMany = flip (*=~)+ makeRegexWith = \o -> compileRegexWith o . unpackR+ makeSearchReplaceWith = \o r t -> compileSearchReplaceWith o (unpackR r) (unpackR t)+ regexSource = packR . reSource -- $tutorial--- We have a regex tutorial at <http://tutorial.regex.uk>. These API--- docs are mainly for reference.---- $toolkit------ Beyond the above match operators and the regular expression type--- below, "Text.RE" contains the toolkit for replacing captures,--- specifying options, etc.---- $re------ "Text.RE.PCRE.RE" contains the toolkit specific to the 'RE' type,--- the type generated by the gegex compiler.+-- We have a regex tutorial at <http://tutorial.regex.uk>.
changelog view
@@ -1,5 +1,16 @@ -*-change-log-*- +0.9.0.0 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-03-23+ * Flip the order of the arguments to replace (#78)+ * Add type-safe replacement templates (#60)+ * Finish tidying up the API (#80)+ * Make `regex` compatible w/ TH-less GHCs (#70)+ * Declare extensions the compiler must support (#83)+ * Fix curl for AppVeyor build (#79)+ * Fix AppVeyor badge (#81)+ * Remove QQ from code coverage stats (#82)+ * Rename Options, Context and Replace methods (#84)+ 0.8.0.0 Chris Dornan <chris.dornan@irisconnect.co.uk> 2017-03-16 * Tidy up the API after recent reorganization (#76)
regex-with-pcre.cabal view
@@ -1,5 +1,5 @@ Name: regex-with-pcre-Version: 0.8.0.0+Version: 0.9.0.0 Synopsis: Toolkit for regex-base Description: A Regular Expression Toolkit for regex-base with Compile-time checking of RE syntax, data types for@@ -22,7 +22,7 @@ README.markdown changelog -Cabal-Version: >= 1.16+Cabal-Version: >= 1.10 Source-Repository head type: git@@ -31,7 +31,7 @@ Source-Repository this Type: git Location: https://github.com/iconnect/regex.git- Tag: 0.8.0.0+ Tag: 0.9.0.0 @@ -46,13 +46,39 @@ Text.RE.PCRE.String Default-Language: Haskell2010++ Other-Extensions:+ AllowAmbiguousTypes+ CPP+ DeriveDataTypeable+ DeriveGeneric+ ExistentialQuantification+ FlexibleContexts+ FlexibleInstances+ FunctionalDependencies+ GeneralizedNewtypeDeriving+ MultiParamTypeClasses+ NoImplicitPrelude+ OverloadedStrings+ QuasiQuotes+ RecordWildCards+ ScopedTypeVariables+ TemplateHaskell+ TypeSynonymInstances+ UndecidableInstances++ if !impl(ghc >= 8.0)+ Other-Extensions: TemplateHaskell+ else+ Other-Extensions: TemplateHaskellQuotes+ GHC-Options: -Wall -fwarn-tabs -Wwarn Build-depends:- regex == 0.8.0.0+ regex == 0.9.0.0 , base >= 4 && < 5 , base-compat >= 0.6.0 , bytestring >= 0.10.2.0