Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Regex :: *
- data RegexException
- data RE = RE {}
- compileRegex :: Bool -> ByteString -> Regex
- matchRegex :: Regex -> ByteString -> Maybe [ByteString]
- convertOctalEscapes :: String -> String
Documentation
data RegexException Source #
An exception in compiling or executing a regex.
A representation of a regular expression.
compileRegex :: Bool -> ByteString -> Regex Source #
Compile a PCRE regex. If the first parameter is True, the regex is
case-sensitive, otherwise caseless. The regex is compiled from
a bytestring interpreted as UTF-8. If the regex cannot be compiled,
a RegexException
is thrown.
matchRegex :: Regex -> ByteString -> Maybe [ByteString] Source #
Match a Regex
against a bytestring. Returns Nothing
if
no match, otherwise Just
a nonempty list of bytestrings. The first
bytestring in the list is the match, the others the captures, if any.
If there are errors in executing the regex, a RegexException
is
thrown.
convertOctalEscapes :: String -> String Source #
Convert octal escapes to the form pcre wants. Note: need at least pcre 8.34 for the form o{dddd}. So we prefer ddd or x{...}.