-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Bindings to the re2 regular expression library -- -- re2 is a regular expression library offering predictable run-time and -- memory consumption. This package is a binding to re2. -- -- Supported expression syntax is documented at -- https://github.com/google/re2/ -- --
-- $ ghci -XOverloadedStrings -- ghci> import Regex.RE2 -- -- ghci> find "\\w+" "hello world" -- Just (Match [Just "hello"]) -- -- ghci> find "\\w+$" "hello world" -- Just (Match [Just "world"]) -- -- ghci> find "^\\w+$" "hello world" -- Nothing --@package re2 @version 0.2 -- | re2 is a regular expression library offering predictable run-time and -- memory consumption. This package is a binding to re2. -- -- Supported expression syntax is documented at -- http://code.google.com/p/re2/wiki/Syntax. -- --
-- $ ghci -XOverloadedStrings -- ghci> import Regex.RE2 -- -- ghci> find "\\w+" "hello world" -- Just (Match [Just "hello"]) -- -- ghci> find "\\w+$" "hello world" -- Just (Match [Just "world"]) -- -- ghci> find "^\\w+$" "hello world" -- Nothing --module Regex.RE2 -- | A pattern is a compiled regular expression plus its compilation -- options. -- -- Patterns can be created by calling compile explicitly: -- --
-- import Data.ByteString.Char8 (pack)
--
-- p :: Pattern
-- p = case compile (pack "^hello world$") of
-- Right ok -> ok
-- Left err -> error ("compilation error: " ++ errorMessage err)
--
--
--
-- Or by using the IsString instance:
--
-- -- import Data.String (fromString) -- -- p :: Pattern -- p = fromString "^hello world$" ---- -- Or by using the OverloadedStrings language extension: -- --
-- {-# LANGUAGE OverloadedStrings #-}
--
-- p :: Pattern
-- p = "^hello world$"
--
data Pattern
-- | -- compile = compileWith defaultOptions --compile :: ByteString -> Either Error Pattern -- | Compile a regular expression with the given options. If compilation -- fails, the error can be inspected with errorMessage and -- errorCode. -- -- Use optionEncoding to select whether the input bytes should be -- interpreted as UTF-8 or Latin1. The default is UTF8. compileWith :: Options -> ByteString -> Either Error Pattern -- | The regular expression originally provided to compileWith. patternInput :: Pattern -> ByteString -- | The options originally provided to compileWith. patternOptions :: Pattern -> Options -- | The capturing groups defined within the pattern. Groups are listed -- from left to right, and are Nothing if the group is unnamed. -- --
-- ghci> patternGroups "(\\d+)|(?P<word>\\w+)" -- fromList [Nothing,Just "word"] --patternGroups :: Pattern -> Vector (Maybe ByteString) -- | Options controlling how to compile a regular expression. The fields in -- this value may be set using record syntax: -- --
-- compileNoCase :: B.ByteString -> Either Error Pattern
-- compileNoCase = compileWith (defaultOptions { optionCaseSensitive = False })
--
--
data Options
-- |
-- defaultOptions = Options
-- { optionEncoding = EncodingUtf8
-- , optionPosixSyntax = False
-- , optionLongestMatch = False
-- , optionMaxMemory = 8388608 -- 8 << 20
-- , optionLiteral = False
-- , optionNeverNewline = False
-- , optionDotNewline = False
-- , optionNeverCapture = False
-- , optionCaseSensitive = True
-- , optionPerlClasses = False
-- , optionWordBoundary = False
-- , optionOneLine = False
-- }
--
--
defaultOptions :: Options
data Encoding
EncodingUtf8 :: Encoding
EncodingLatin1 :: Encoding
optionEncoding :: Options -> Encoding
optionPosixSyntax :: Options -> Bool
optionLongestMatch :: Options -> Bool
optionMaxMemory :: Options -> Int64
optionLiteral :: Options -> Bool
optionNeverNewline :: Options -> Bool
optionNeverCapture :: Options -> Bool
optionCaseSensitive :: Options -> Bool
-- | Only checked in posix mode
optionPerlClasses :: Options -> Bool
-- | Only checked in posix mode
optionWordBoundary :: Options -> Bool
-- | Only checked in posix mode
optionOneLine :: Options -> Bool
data Error
data ErrorCode
ErrorInternal :: ErrorCode
ErrorBadEscape :: ErrorCode
ErrorBadCharClass :: ErrorCode
ErrorBadCharRange :: ErrorCode
ErrorMissingBracket :: ErrorCode
ErrorMissingParen :: ErrorCode
ErrorTrailingBackslash :: ErrorCode
ErrorRepeatArgument :: ErrorCode
ErrorRepeatSize :: ErrorCode
ErrorRepeatOp :: ErrorCode
ErrorBadPerlOp :: ErrorCode
ErrorBadUTF8 :: ErrorCode
ErrorBadNamedCapture :: ErrorCode
ErrorPatternTooLarge :: ErrorCode
errorMessage :: Error -> String
errorCode :: Error -> ErrorCode
-- | A successful match of the pattern against some input. Capturing groups
-- may be retrieved with matchGroup or matchGroups.
data Match
-- | The capturing group with the given index, or Nothing if the
-- group was not set in this match.
--
-- The entire match is group 0.
matchGroup :: Match -> Int -> Maybe ByteString
-- | All of the groups in the pattern, with each group being
-- Nothing if it was not set in this match. Groups are returned
-- in the same order as patternGroups.
--
-- The entire match is group 0.
matchGroups :: Match -> Vector (Maybe ByteString)
data Anchor
AnchorStart :: Anchor
AnchorBoth :: Anchor
-- | The most general matching function. Attempt to match the pattern to
-- the input within the given constraints.
--
-- If the number of match groups to populate is 0, matching can be
-- performed more efficiently.
match :: Pattern -> ByteString -> Int -> Int -> Maybe Anchor -> Int -> Maybe Match
-- | Attempt to find the pattern somewhere within the input.
find :: Pattern -> ByteString -> Maybe Match
-- | Replace the first occurance of the pattern with the given replacement
-- template. If the template contains backslash escapes such as
-- \1, the capture group with the given index will be inserted
-- in their place.
--
-- Returns the new bytes, and True if a replacement occured.
replace :: Pattern -> ByteString -> ByteString -> (ByteString, Bool)
-- | Replace every occurance of the pattern with the given replacement
-- template. If the template contains backslash escapes such as
-- \1, the capture group with the given index will be inserted
-- in their place.
--
-- Returns the new bytes, and how many replacements occured.
replaceAll :: Pattern -> ByteString -> ByteString -> (ByteString, Int)
-- | Attempt to find the pattern somewhere within the input, and extract it
-- using the given template. If the template contains backslash escapes
-- such as \1, the capture group with the given index will be
-- inserted in their place.
--
-- Returns Nothing if the pattern was not found in the input.
extract :: Pattern -> ByteString -> ByteString -> Maybe ByteString
-- | Escapes bytes such that the output is a regular expression which will
-- exactly match the input.
quoteMeta :: ByteString -> ByteString
instance GHC.Show.Show Regex.RE2.Anchor
instance GHC.Classes.Eq Regex.RE2.Anchor
instance GHC.Classes.Eq Regex.RE2.Match
instance GHC.Show.Show Regex.RE2.Options
instance GHC.Classes.Eq Regex.RE2.Options
instance GHC.Show.Show Regex.RE2.Encoding
instance GHC.Classes.Eq Regex.RE2.Encoding
instance GHC.Show.Show Regex.RE2.Error
instance GHC.Classes.Eq Regex.RE2.Error
instance GHC.Show.Show Regex.RE2.ErrorCode
instance GHC.Classes.Eq Regex.RE2.ErrorCode
instance GHC.Show.Show Regex.RE2.Match
instance GHC.Show.Show Regex.RE2.Pattern
instance GHC.Classes.Eq Regex.RE2.Pattern
instance Data.String.IsString Regex.RE2.Pattern