Safe Haskell | None |
---|---|
Language | Haskell2010 |
Text.RE.PCRE
Contents
- (*=~) :: IsRegex RE s => s -> RE -> Matches s
- (?=~) :: IsRegex RE s => s -> RE -> Match s
- (*=~/) :: IsRegex RE s => s -> SearchReplace RE s -> s
- (?=~/) :: IsRegex RE s => s -> SearchReplace RE s -> s
- (=~) :: (RegexContext Regex s a, RegexMaker Regex CompOption ExecOption s) => s -> RE -> a
- (=~~) :: (Monad m, RegexContext Regex s a, RegexMaker Regex CompOption ExecOption s) => s -> RE -> m a
- data Matches a :: * -> *
- matchesSource :: Matches a -> a
- allMatches :: Matches a -> [Match a]
- anyMatches :: Matches a -> Bool
- countMatches :: Matches a -> Int
- matches :: Matches a -> [a]
- data Match a :: * -> *
- matchSource :: Match a -> a
- matched :: Match a -> Bool
- matchedText :: Match a -> Maybe a
- data RE
- data SimpleREOptions :: *
- reSource :: RE -> String
- compileRegex :: (Functor m, Monad m) => String -> m RE
- compileRegexWith :: (Functor m, Monad m) => SimpleREOptions -> String -> m RE
- escape :: (Functor m, Monad m) => (String -> String) -> String -> m RE
- escapeWith :: (Functor m, Monad m) => SimpleREOptions -> (String -> String) -> String -> m RE
- escapeREString :: String -> String
- module Text.RE.PCRE.RE
- ed :: QuasiQuoter
- edMS :: QuasiQuoter
- edMI :: QuasiQuoter
- edBS :: QuasiQuoter
- edBI :: QuasiQuoter
- edMultilineSensitive :: QuasiQuoter
- edMultilineInsensitive :: QuasiQuoter
- edBlockSensitive :: QuasiQuoter
- edBlockInsensitive :: QuasiQuoter
- ed_ :: QuasiQuoter
- module Text.RE.PCRE.ByteString
- module Text.RE.PCRE.ByteString.Lazy
- module Text.RE.PCRE.Sequence
- module Text.RE.PCRE.String
Tutorial
We have a regex tutorial at http://tutorial.regex.uk.
About this Module
This module provides access to the back end through polymorphic functions that operate over all of the StringTextByteString types supported by the PCRE back end. If you don't need this generality you might find it easier to work with one of the modules that have been specialised for each of these types:
The Match Operators
(*=~) :: IsRegex RE s => s -> RE -> Matches s Source #
find all matches in text; e.g., to count the number of naturals in s:
countMatches $ s *=~ [re|[0-9]+|]
The SearchReplace Operators
The Classic rexex-base Match Operators
(=~) :: (RegexContext Regex s a, RegexMaker Regex CompOption ExecOption s) => s -> RE -> a Source #
the regex-base polymorphic match operator
(=~~) :: (Monad m, RegexContext Regex s a, RegexMaker Regex CompOption ExecOption s) => s -> RE -> m a Source #
the regex-base monadic, polymorphic match operator
Matches
the result type to use when every match is needed, not just the first match of the RE against the source
matchesSource :: Matches a -> a #
the source text being matched
allMatches :: Matches a -> [Match a] #
all Match
instances found, left to right
anyMatches :: Matches a -> Bool #
tests whether the RE matched the source text at all
countMatches :: Matches a -> Int #
count the matches
Match
the result of matching a RE to a text once, listing the text that was matched and the named captures in the RE and all of the substrings matched, with the text captured by the whole RE; a complete failure to match will be represented with an empty array (with bounds (0,-1))
Instances
matchSource :: Match a -> a #
the whole source text
matchedText :: Match a -> Maybe a #
tests whether the RE matched the source text at all
The RE
Type and Functions
the RE type for this back end representing a well-formed, compiled RE
Instances
data SimpleREOptions :: * #
the default API uses these simple, universal RE options,
which get auto-converted into the apropriate REOptions_
actually
as apropriate the chosen back end
Constructors
MultilineSensitive | case-sensitive with ^ and $ matching the start and end of a line |
MultilineInsensitive | case-insensitive with ^ and $ matsh the start and end of a line |
BlockSensitive | case-sensitive with ^ and $ matching the start and end of the input text |
BlockInsensitive | case-insensitive with ^ and $ matching the start and end of the input text |
Instances
Bounded SimpleREOptions | |
Enum SimpleREOptions | |
Eq SimpleREOptions | |
Ord SimpleREOptions | |
Show SimpleREOptions | |
Lift SimpleREOptions | we need to use this in the quasi quoters to specify |
compileRegexWith :: (Functor m, Monad m) => SimpleREOptions -> String -> m RE Source #
escape :: (Functor m, Monad m) => (String -> String) -> String -> m RE Source #
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
escapeWith :: (Functor m, Monad m) => SimpleREOptions -> (String -> String) -> String -> m RE Source #
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
escapeREString :: String -> String #
Convert a string into a regular expression that will amtch that string
module Text.RE.PCRE.RE
The [ed| ... |] quasi quoters
ed :: QuasiQuoter Source #
the [ed| ... /// ... |]
quasi quoters
edMS :: QuasiQuoter Source #
the [ed| ... /// ... |]
quasi quoters
edMI :: QuasiQuoter Source #
the [ed| ... /// ... |]
quasi quoters
edBS :: QuasiQuoter Source #
the [ed| ... /// ... |]
quasi quoters
edBI :: QuasiQuoter Source #
the [ed| ... /// ... |]
quasi quoters
edMultilineSensitive :: QuasiQuoter Source #
the [ed| ... /// ... |]
quasi quoters
edMultilineInsensitive :: QuasiQuoter Source #
the [ed| ... /// ... |]
quasi quoters
edBlockSensitive :: QuasiQuoter Source #
the [ed| ... /// ... |]
quasi quoters
edBlockInsensitive :: QuasiQuoter Source #
the [ed| ... /// ... |]
quasi quoters
ed_ :: QuasiQuoter Source #
the [ed| ... /// ... |]
quasi quoters
The Operator Instances
These modules merely provide the IsRegex
instances.
module Text.RE.PCRE.ByteString
module Text.RE.PCRE.ByteString.Lazy
module Text.RE.PCRE.Sequence
module Text.RE.PCRE.String