pcre-utils-0.1.0.2: Perl-like substitute and split for PCRE regexps.

Safe HaskellNone

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

Documentation

substituteSource

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 ..

splitSource

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.

substituteCompileSource

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

splitCompileSource

Arguments

:: ByteString

The regular expression

-> ByteString

The source string

-> IO (Either String [ByteString]) 

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