regex-do-1.9: PCRE wrapper

Safe HaskellNone
LanguageHaskell2010

Text.Regex.Do.Pcre.ReplaceOpen

Description

extensible and reusable replacement functions

Run replacement with your preferred content types e.g. Data.Text, from search results with non-PCRE regex or non-regex libs

open a bug or a PR on git to request a new ReplaceOpen instance

Synopsis

Documentation

class Extract a => Extract' a where Source

see String, ByteString instances for implementation examples

see Text.Regex.Base.RegexLike for Extract detail

Methods

concat' :: [a] -> a Source

len' :: a -> Int Source

defaultReplacer Source

Arguments

:: Extract' a 
=> Int

group idx

-> (a -> a)

(group match -> replacement) tweak

-> GroupReplacer a 

Replaces specified (by idx) group match with tweaked value. Works for one common simple use case

GroupReplacer can be used with complicated regex

another custom dynamic replacer could e.g.

inspect all group matches before looking up a replacement.

getGroup :: Extract a => ReplaceAcc a -> MatchArray -> Int -> Maybe a Source

get group content safely

see defaultReplacer source for use example

replaceMatch Source

Arguments

:: Extract' a 
=> PosLen

replaceable, unadjusted

-> (a, ReplaceAcc a)

(new val, acc passed to GroupReplacer)

-> ReplaceAcc a

new acc

call from your custom GroupReplacer passed to replaceGroup

see defaultReplacer source for use example