    module Text.RE.ZeInternals.EscapeREString where

    -- | Convert a string into a regular expression that will match that
    -- string
    escapeREString :: String -> String
    escapeREString :: String -> String
    escapeREString = (Char -> String -> String) -> String -> String -> String
    forall a b. (a -> b -> b) -> b -> [a] -> b
    forall (t :: * -> *) a b.
    Foldable t =>
    (a -> b -> b) -> b -> t a -> b
    foldr Char -> String -> String
    esc []
      where
        esc :: Char -> String -> String
    esc Char
    c String
    t | Char -> Bool
    isMetaChar Char
    c = Char
    '\\' Char -> String -> String
    forall a. a -> [a] -> [a]
    : Char
    c Char -> String -> String
    forall a. a -> [a] -> [a]
    : String
    t
                | Bool
    otherwise    = Char
    c Char -> String -> String
    forall a. a -> [a] -> [a]
    : String
    t

    -- | returns True iff the character is an RE meta character
    -- ('[', '*', '{', etc.)
    isMetaChar :: Char -> Bool
    isMetaChar :: Char -> Bool
    isMetaChar Char
    c = case Char
    c of
      Char
    '^'  -> Bool
    True
      Char
    '\\' -> Bool
    True
      Char
    '.'  -> Bool
    True
      Char
    '|'  -> Bool
    True
      Char
    '*'  -> Bool
    True
      Char
    '?'  -> Bool
    True
      Char
    '+'  -> Bool
    True
      Char
    '('  -> Bool
    True
      Char
    ')'  -> Bool
    True
      Char
    '['  -> Bool
    True
      Char
    ']'  -> Bool
    True
      Char
    '{'  -> Bool
    True
      Char
    '}'  -> Bool
    True
      Char
    '$'  -> Bool
    True
      Char
    _    -> Bool
    False