diff --git a/README.markdown b/README.markdown
--- a/README.markdown
+++ b/README.markdown
@@ -62,7 +62,7 @@
 
 &nbsp;&nbsp;&nbsp;&nbsp;&#x2612;&nbsp;&nbsp;2017-03-16  v0.8.0.0  [Tidy up the API](https://github.com/iconnect/regex/milestone/10)
 
-&nbsp;&nbsp;&nbsp;&nbsp;&#x2610;&nbsp;&nbsp;2017-03-18  v0.9.0.0  [Add type-safe replacement templates and use TemplateHaskellQuotes](https://github.com/iconnect/regex/milestone/9)
+&nbsp;&nbsp;&nbsp;&nbsp;&#x2612;&nbsp;&nbsp;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)
 
 &nbsp;&nbsp;&nbsp;&nbsp;&#x2610;&nbsp;&nbsp;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.
 
-&nbsp;&nbsp;&nbsp;&nbsp;`t` [&#64;hregex](https://twitter.com/hregex)
-
-&nbsp;&nbsp;&nbsp;&nbsp;`e` maintainers@regex.uk
-
+&nbsp;&nbsp;&nbsp;&nbsp;`t` [&#64;hregex](https://twitter.com/hregex)\n
+&nbsp;&nbsp;&nbsp;&nbsp;`e` maintainers@regex.uk\n
 &nbsp;&nbsp;&nbsp;&nbsp;`w` http://issues.regex.uk
 
 The [Contact page](http://contact.regex.uk) has more details.
diff --git a/Text/RE/PCRE.hs b/Text/RE/PCRE.hs
--- a/Text/RE/PCRE.hs
+++ b/Text/RE/PCRE.hs
@@ -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
 --
diff --git a/Text/RE/PCRE/ByteString.hs b/Text/RE/PCRE/ByteString.hs
--- a/Text/RE/PCRE/ByteString.hs
+++ b/Text/RE/PCRE/ByteString.hs
@@ -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>.
diff --git a/Text/RE/PCRE/ByteString/Lazy.hs b/Text/RE/PCRE/ByteString/Lazy.hs
--- a/Text/RE/PCRE/ByteString/Lazy.hs
+++ b/Text/RE/PCRE/ByteString/Lazy.hs
@@ -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>.
diff --git a/Text/RE/PCRE/RE.hs b/Text/RE/PCRE/RE.hs
--- a/Text/RE/PCRE/RE.hs
+++ b/Text/RE/PCRE/RE.hs
@@ -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
diff --git a/Text/RE/PCRE/Sequence.hs b/Text/RE/PCRE/Sequence.hs
--- a/Text/RE/PCRE/Sequence.hs
+++ b/Text/RE/PCRE/Sequence.hs
@@ -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>.
diff --git a/Text/RE/PCRE/String.hs b/Text/RE/PCRE/String.hs
--- a/Text/RE/PCRE/String.hs
+++ b/Text/RE/PCRE/String.hs
@@ -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>.
diff --git a/changelog b/changelog
--- a/changelog
+++ b/changelog
@@ -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)
 
diff --git a/regex-with-pcre.cabal b/regex-with-pcre.cabal
--- a/regex-with-pcre.cabal
+++ b/regex-with-pcre.cabal
@@ -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
