Safe Haskell | None |
---|
This module provides perl-style pattern matching. It is intended
for use with minimal Haskell knowledge, so it moves away from the
complex regex-* type signatures for the sake of clarity, and always
uses the same string types for source text and patterns. See
tests
in source code for a few examples.
- module Text.Regex.PCRE
- type Match = SBS
- type Source = LBS
- (=~+) :: Source -> Match -> [(Source, (MatchOffset, MatchLength))]
- (=~-) :: Source -> Match -> [Source]
- (=~#) :: Source -> Match -> Bool
- (=~++) :: Source -> Match -> [[(Source, (MatchOffset, MatchLength))]]
- replaceRegex :: Source -> Match -> ([(Source, (MatchOffset, MatchLength))] -> Maybe Source) -> Source
- replaceRegexAll :: Source -> Match -> ([(Source, (MatchOffset, MatchLength))] -> Maybe Source) -> Source
Documentation
module Text.Regex.PCRE
(=~+) :: Source -> Match -> [(Source, (MatchOffset, MatchLength))]Source
Convenience wrapper around '(=~)', that trades flexibility off for compactness.
(=~-) :: Source -> Match -> [Source]Source
Convenience wrapper for '(=~+)' that chops rarely needed offsets and lengths off the result.
(=~++) :: Source -> Match -> [[(Source, (MatchOffset, MatchLength))]]Source
Like '(=~+)', but find all matches, not just the first one.
replaceRegex :: Source -> Match -> ([(Source, (MatchOffset, MatchLength))] -> Maybe Source) -> SourceSource
Replace first match with result of a function of the match.
replaceRegexAll :: Source -> Match -> ([(Source, (MatchOffset, MatchLength))] -> Maybe Source) -> SourceSource
Replace all matches with result of a function of the match.