HORIZON HASKELLDocslts/ghc-9.14.x7a6c33e2026-10-12Search packagesCtrl K
Theme: |

GHC 9.14.1 · lts/ghc-9.14.x · 7a6c33e · 2026-10-12

  • Packageregex-1.1.0.2
  • Exports45
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceReplace.lhs

The Replacing Tutorial

This API module covers the specialised regex tools for doing general editing on text, including the internal details of the Matches and Match types and the associated functions for extracting captures and applying functions to them to transform the subject text.

See the tutorials at http://re-tutorial-replacing.regex.uk

replaceAll

replace

REContext and RELocation

datadata REContext

REContext specifies which contexts the substitutions should be applied

Constructors

  • TOP

    substitutions should be applied to the top-level only, the text that matched the whole RE

  • SUB

    substitutions should only be applied to the text captured by bracketed sub-REs

  • ALL

    the substitution function should be applied to all captures, the top level and the sub-expression captures

Instances1Show
  • Show REContextDefined in regex-1.1.0.2 · Text.RE.ZeInternals.Replace
datadata RELocation

the RELocation information passed into the substitution function specifies which sub-expression is being substituted

Constructors

  • RELocation
    • locationMatch :: Int

      the zero-based, i-th string to be matched, when matching all strings, zero when only the first string is being matched

    • locationCapture :: CaptureOrdinal

      0, when matching the top-level string matched by the whole RE, 1 for the top-most, left-most redex captured by bracketed sub-REs, etc.

Instances1Show
  • Show RELocationDefined in regex-1.1.0.2 · Text.RE.ZeInternals.Replace

Matches

datadata Matches a

the result of matching a RE against a text (with *=~), retaining the text that was matched against

Constructors

Instances4Functor, RegexContext, Eq, Show
  • Functor MatchesDefined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.Matches
  • (RegexContext regex source [MatchText source], RegexLike regex source, RegexFix regex source) => RegexContext regex source (Matches source)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.Matches

    this instance hooks Matches into regex-base: regex consumers need not worry about any of this

  • Eq a => Eq (Matches a)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.Matches
  • Show a => Show (Matches a)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.Matches

Match

datadata Match a

the result of matching a RE to a text once (with ?=~), retaining the text that was matched against

Constructors

Instances4Functor, RegexContext, Eq, Show
  • Functor MatchDefined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.Match
  • (RegexContext regex source (AllTextSubmatches (Array Int) (source, (Int, Int))), RegexLike regex source, RegexFix regex source) => RegexContext regex source (Match source)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.Match

    this instance hooks Match into regex-base: regex consumers need not worry about any of this

  • Eq a => Eq (Match a)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.Match
  • Show a => Show (Match a)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.Match
valuecaptureText :: CaptureID -> Match a -> a

look up the text of the nth capture, 0 being the match of the whole RE against the source text, 1, the first bracketed sub-expression to be matched and so on

valuecapture :: CaptureID -> Match a -> Capture a

look up the nth capture, 0 being the match of the whole RE against the source text, 1, the first bracketed sub-expression to be matched and so on

look up the nth capture, 0 being the match of the whole RE against the source text, 1, the first bracketed sub-expression to be matched and so on, returning Nothing if there is no such capture, or if the capture failed to capture anything (being in a failed alternate)

Capture

datadata Capture a

the matching of a single sub-expression against part of the source text

Constructors

Instances3Functor, Eq, Show
  • Functor CaptureDefined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.Capture
  • Eq a => Eq (Capture a)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.Capture
  • Show a => Show (Capture a)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.Capture

CaptureID

newtypenewtype CaptureOrdinal

a CaptureOrdinal is just the number of the capture, starting with 0 for the whole of the text matched, then in leftmost, outermost

Instances6Enum, Eq, Num, Ord, Show, Ix

Replace and ReplaceMethods

classclass (Show a, Eq a, Ord a, Extract a, Monoid a) => Replace a where

Replace provides the missing needed to replace the matched text in a Replace a => Match a.

Methods

Instances6Replace
  • Replace ByteStringDefined in regex-1.1.0.2 · Text.RE.ZeInternals.Replace
  • Replace ByteStringDefined in regex-1.1.0.2 · Text.RE.ZeInternals.Replace
  • Replace TextDefined in regex-1.1.0.2 · Text.RE.ZeInternals.Replace
  • Replace TextDefined in regex-1.1.0.2 · Text.RE.ZeInternals.Replace
  • Replace (Seq Char)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Replace
  • Replace [Char]Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Replace