pcre-utils-0.1.9: Perl-like substitute and split for PCRE regexps.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Text.Regex.PCRE.ByteString.Utils

Description

A module implementing regexp-based split and substitute.

>>> substituteCompile "(a+)" "lapin" "'\\1'"
Right "l'a'pin"
>>> splitCompile "\\d" "a1b2c3"
Right ["a","b","c"]
Synopsis

Perl-like utility functions

substitute Source #

Arguments

:: Regex

The regular expression, taken from a call to compile

-> ByteString

The source string

-> ByteString

The replacement string

-> IO (Either String ByteString) 

Substitutes values matched by a Regex. References can be used.

It doesn't support anything else than global substitution for now ..

split Source #

Arguments

:: Regex

The regular expression, taken from a call to compile

-> ByteString

The source string

-> IO (Either String [ByteString]) 

Splits strings, using a Regex as delimiter.

substituteCompile Source #

Arguments

:: ByteString

The regular expression

-> ByteString

The source string

-> ByteString

The replacement string

-> IO (Either String ByteString) 

Compiles the regular expression (using default options) and substitutes

splitCompile Source #

Arguments

:: ByteString

The regular expression

-> ByteString

The source string

-> IO (Either String [ByteString]) 

Compiles the regular expression (using default options) and splits.

Re-exports from Text.Regex.PCRE.ByteString

data CompOption #

Instances

Instances details
Bits CompOption 
Instance details

Defined in Text.Regex.PCRE.Wrap

Num CompOption 
Instance details

Defined in Text.Regex.PCRE.Wrap

Show CompOption 
Instance details

Defined in Text.Regex.PCRE.Wrap

Eq CompOption 
Instance details

Defined in Text.Regex.PCRE.Wrap

RegexOptions Regex CompOption ExecOption 
Instance details

Defined in Text.Regex.PCRE.Wrap

data ExecOption #

Instances

Instances details
Bits ExecOption 
Instance details

Defined in Text.Regex.PCRE.Wrap

Num ExecOption 
Instance details

Defined in Text.Regex.PCRE.Wrap

Show ExecOption 
Instance details

Defined in Text.Regex.PCRE.Wrap

Eq ExecOption 
Instance details

Defined in Text.Regex.PCRE.Wrap

RegexOptions Regex CompOption ExecOption 
Instance details

Defined in Text.Regex.PCRE.Wrap

Pure version of the functions, using unsafePerformIO

compile' :: CompOption -> ExecOption -> ByteString -> Either (MatchOffset, String) Regex Source #

A pure version of compile, using unsafePerformIO.

execute' :: Regex -> ByteString -> Either WrapError (Maybe (Array Int (MatchOffset, MatchLength))) Source #

A pure version of execute, using unsafePerformIO.

substitute' Source #

Arguments

:: Regex

The regular expression, taken from a call to compile

-> ByteString

The source string

-> ByteString

The replacement string

-> Either String ByteString 

A pure version of substitute, using unsafePerformIO.

split' Source #

Arguments

:: Regex

The regular expression, taken from a call to compile

-> ByteString

The source string

-> Either String [ByteString] 

A pure version of split, using unsafePerformIO.

substituteCompile' Source #

Arguments

:: ByteString

The regular expression

-> ByteString

The source string

-> ByteString

The replacement string

-> Either String ByteString 

A pure version of substituteCompile, using unsafePerformIO.

splitCompile' Source #

Arguments

:: ByteString

The regular expression

-> ByteString

The source string

-> Either String [ByteString] 

A pure version of splitCompile, using unsafePerformIO.