regex-do-2.6.1: PCRE wrapper

Safe HaskellNone
LanguageHaskell2010

Text.Regex.Do.Format

Description

placeholder syntax:

  • index based

    { Int }

other placeholders may be implemented with

Text.Regex.Do.Pcre.Ascii.Replace or Text.Regex.Do.Pcre.Utf8.Replace

Synopsis

Documentation

class Format a arg where Source

implemented a:

Methods

format Source

Arguments

:: a

text to format e.g. "today is {0}"

-> arg

replacement: [a] or [(a,a)]

-> a

formatted text

Instances

ReplaceOne a a => Format a [(a, a)] Source

key based

key may be {any a}

>>> format "овчинка {a} не {b}" [("a","выделки"),("b","стоит")]

"овчинка выделки не стоит"

ReplaceOne Int a => Format a [a] Source

index based

>>> format "на первое {0}, на второе {0}" ["перловка"]

"на первое перловка, на второе перловка"

>>> format "Polly {0} a {1}" ["got","cracker"]

"Polly got a cracker"

type Formatable a = (Format a [a], Format a [(a, a)]) Source