regex-1.1.0.2: Toolkit for regex-base

Safe Haskell | None
Language | Haskell2010

Text.RE.Replace

Contents

- The Replacing Tutorial
- replaceAll
- replace
- REContext and RELocation
- Matches
- Match
- Capture
- CaptureID
- Replace and ReplaceMethods

Synopsis

- replaceAll :: Replace a => a -> Matches a -> a
- replaceAllCaptures :: Replace a => REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Matches a -> a
- replaceAllCaptures_ :: Extract a => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Matches a -> a
- replaceAllCapturesM :: (Extract a, Monad m) => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> m (Maybe a)) -> Matches a -> m a
- replace :: Replace a => a -> Match a -> a
- replaceCaptures :: Replace a => REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Match a -> a
- replaceCaptures_ :: Extract a => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Match a -> a
- replaceCapturesM :: (Monad m, Extract a) => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> m (Maybe a)) -> Match a -> m a
- data REContext
  - = TOP
  - | SUB
  - | ALL
- data RELocation = RELocation {
  - locationMatch :: Int
  - locationCapture :: CaptureOrdinal
  }
- isTopLocation :: RELocation -> Bool
- data Matches a = Matches {
  - matchesSource :: !a
  - allMatches :: ![Match a]
  }
- anyMatches :: Matches a -> Bool
- countMatches :: Matches a -> Int
- matches :: Matches a -> [a]
- mainCaptures :: Matches a -> [Capture a]
- data Match a = Match {
  - matchSource :: !a
  - captureNames :: !CaptureNames
  - matchArray :: !(Array CaptureOrdinal (Capture a))
  }
- noMatch :: a -> Match a
- emptyMatchArray :: Array CaptureOrdinal (Capture a)
- matched :: Match a -> Bool
- matchedText :: Match a -> Maybe a
- matchCapture :: Match a -> Maybe (Capture a)
- matchCaptures :: Match a -> Maybe (Capture a, [Capture a])
- (!$$) :: Match a -> CaptureID -> a
- captureText :: CaptureID -> Match a -> a
- (!$$?) :: Match a -> CaptureID -> Maybe a
- captureTextMaybe :: CaptureID -> Match a -> Maybe a
- (!$) :: Match a -> CaptureID -> Capture a
- capture :: CaptureID -> Match a -> Capture a
- (!$?) :: Match a -> CaptureID -> Maybe (Capture a)
- captureMaybe :: CaptureID -> Match a -> Maybe (Capture a)
- convertMatchText :: RegexFix regex source => regex -> source -> MatchText source -> Match source
- data Capture a = Capture {
  - captureSource :: !a
  - capturedText :: !a
  - captureOffset :: !Int
  - captureLength :: !Int
  }
- hasCaptured :: Capture a -> Bool
- capturePrefix :: Extract a => Capture a -> a
- captureSuffix :: Extract a => Capture a -> a
- data CaptureID
  - = IsCaptureOrdinal CaptureOrdinal
  - | IsCaptureName CaptureName
- type CaptureNames = HashMap CaptureName CaptureOrdinal
- noCaptureNames :: CaptureNames
- newtype CaptureName = CaptureName {
  - getCaptureName :: Text
  }
- newtype CaptureOrdinal = CaptureOrdinal {
  - getCaptureOrdinal :: Int
  }
- findCaptureID :: CaptureID -> CaptureNames -> Either String CaptureOrdinal
- class (Show a, Eq a, Ord a, Extract a, Monoid a) => Replace a where
  - lengthR :: a -> Int
  - packR :: String -> a
  - unpackR :: a -> String
  - textifyR :: a -> Text
  - detextifyR :: Text -> a
  - linesR :: a -> [a]
  - unlinesR :: [a] -> a
  - appendNewlineR :: a -> a
  - substR :: (a -> a) -> Capture a -> a
  - parseTemplateR :: a -> Match a -> RELocation -> Capture a -> Maybe a
- data ReplaceMethods a = ReplaceMethods {
  - methodLength :: a -> Int
  - methodSubst :: (a -> a) -> Capture a -> a
  }
- replaceMethods :: Replace a => ReplaceMethods a

# 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

replaceAll :: Replace a => a -> Matches a -> a Source #

replace all with a template, $0 for whole text, $1 for first capture, etc.

replaceAllCaptures :: Replace a => REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Matches a -> a Source #

substitutes using a function that takes the full Match context and returns the same replacement text as the _phi_phi context.

replaceAllCaptures_ :: Extract a => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Matches a -> a Source #

replaceAllCaptures_ is like like replaceAllCaptures but takes the Replace methods through the ReplaceMethods argument

replaceAllCapturesM :: (Extract a, Monad m) => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> m (Maybe a)) -> Matches a -> m a Source #

replaceAllCapturesM is just a monadically generalised version of replaceAllCaptures_

# replace

replace :: Replace a => a -> Match a -> a Source #

replaceCaptures :: Replace a => REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Match a -> a Source #

substitutes using a function that takes the full Match context and returns the same replacement text as the _phi_phi context.

replaceCaptures_ :: Extract a => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> Maybe a) -> Match a -> a Source #

replaceCaptures_ is like replaceCaptures but takes the Replace methods through the ReplaceMethods argument

replaceCapturesM :: (Monad m, Extract a) => ReplaceMethods a -> REContext -> (Match a -> RELocation -> Capture a -> m (Maybe a)) -> Match a -> m a Source #

replaceCapturesM is just a monadically generalised version of replaceCaptures_

# REContext and RELocation

data REContext Source #

`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

#### Instances

Instances details

Show REContext Source # |
Instance details Defined in Text.RE.ZeInternals.Replace Methods showsPrec :: Int -> REContext -> ShowS Source # show :: REContext -> String Source # showList :: [REContext] -> ShowS Source #

data RELocation Source #

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

Constructors

RELocation |

Fields

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

#### Instances

Instances details

Show RELocation Source # |
Instance details Defined in Text.RE.ZeInternals.Replace Methods showsPrec :: Int -> RELocation -> ShowS Source # show :: RELocation -> String Source # showList :: [RELocation] -> ShowS Source #

isTopLocation :: RELocation -> Bool Source #

True iff the location references a complete match (i.e., not a bracketed capture)

# Matches

data Matches a Source #

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

Constructors

Matches |

Fields

- matchesSource :: !a

  the source text being matched

- allMatches :: ![Match a]

  all `Match` instances found, left to right

#### Instances

Instances details

Functor Matches Source # |
Instance details Defined in Text.RE.ZeInternals.Types.Matches Methods fmap :: (a -> b) -> Matches a -> Matches b Source # (<$) :: a -> Matches b -> Matches a Source #
(RegexContext regex source [MatchText source], RegexLike regex source, RegexFix regex source) => RegexContext regex source (Matches source) Source # | this instance hooks `Matches` into regex-base: regex consumers need not worry about any of this
Instance details Defined in Text.RE.ZeInternals.Types.Matches Methods match :: regex -> source -> Matches source Source # matchM :: MonadFail m => regex -> source -> m (Matches source) Source #
Show a => Show (Matches a) Source # |
Instance details Defined in Text.RE.ZeInternals.Types.Matches Methods showsPrec :: Int -> Matches a -> ShowS Source # show :: Matches a -> String Source # showList :: [Matches a] -> ShowS Source #
Eq a => Eq (Matches a) Source # |
Instance details Defined in Text.RE.ZeInternals.Types.Matches Methods (==) :: Matches a -> Matches a -> Bool Source # (/=) :: Matches a -> Matches a -> Bool Source #

anyMatches :: Matches a -> Bool Source #

tests whether the RE matched the source text at all

countMatches :: Matches a -> Int Source #

count the matches

matches :: Matches a -> [a] Source #

list the texts that Matched

mainCaptures :: Matches a -> [Capture a] Source #

extract the main capture from each match

# Match

data Match a Source #

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

Constructors

Match |

Fields

- matchSource :: !a

  the whole source text

- captureNames :: !CaptureNames

  the RE's capture names

- matchArray :: !(Array CaptureOrdinal (Capture a))
  1. .n-1 captures, starting with the text matched by the whole RE

#### Instances

Instances details

Functor Match Source # |
Instance details Defined in Text.RE.ZeInternals.Types.Match Methods fmap :: (a -> b) -> Match a -> Match b Source # (<$) :: a -> Match b -> Match a Source #
(RegexContext regex source (AllTextSubmatches (Array Int) (source, (Int, Int))), RegexLike regex source, RegexFix regex source) => RegexContext regex source (Match source) Source # | this instance hooks `Match` into regex-base: regex consumers need not worry about any of this
Instance details Defined in Text.RE.ZeInternals.Types.Match Methods match :: regex -> source -> Match source Source # matchM :: MonadFail m => regex -> source -> m (Match source) Source #
Show a => Show (Match a) Source # |
Instance details Defined in Text.RE.ZeInternals.Types.Match Methods showsPrec :: Int -> Match a -> ShowS Source # show :: Match a -> String Source # showList :: [Match a] -> ShowS Source #
Eq a => Eq (Match a) Source # |
Instance details Defined in Text.RE.ZeInternals.Types.Match Methods (==) :: Match a -> Match a -> Bool Source # (/=) :: Match a -> Match a -> Bool Source #

noMatch :: a -> Match a Source #

Construct a Match that does not match anything.

emptyMatchArray :: Array CaptureOrdinal (Capture a) Source #

an empty array of Capture

matched :: Match a -> Bool Source #

tests whether the RE matched the source text at all

matchedText :: Match a -> Maybe a Source #

yields the text matched by the RE, Nothing if no match

matchCapture :: Match a -> Maybe (Capture a) Source #

the top-level capture if the source text matched the RE, Nothing otherwise

matchCaptures :: Match a -> Maybe (Capture a, [Capture a]) Source #

the main top-level capture (capture '0'') and the sub captures if the text matched the RE, `Nothing` otherwise

(!$$) :: Match a -> CaptureID -> a infixl 9 Source #

an alternative for captureText

captureText :: CaptureID -> Match a -> a Source #

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

(!$$?) :: Match a -> CaptureID -> Maybe a Source #

an alternative for captureTextMaybe

captureTextMaybe :: CaptureID -> Match a -> Maybe a Source #

look up the text of the nth capture (0 being the match of the whole), returning Nothing if the Match doesn't contain the capture

(!$) :: Match a -> CaptureID -> Capture a infixl 9 Source #

an alternative for capture

capture :: CaptureID -> Match a -> Capture a Source #

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

(!$?) :: Match a -> CaptureID -> Maybe (Capture a) Source #

an alternative for capture captureMaybe

captureMaybe :: CaptureID -> Match a -> Maybe (Capture a) Source #

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)

convertMatchText :: RegexFix regex source => regex -> source -> MatchText source -> Match source Source #

convert a regex-base native MatchText into a regex Match type

# Capture

data Capture a Source #

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

Constructors

Capture |

Fields

- captureSource :: !a

  the whole text that was searched

- capturedText :: !a

  the text that was matched

- captureOffset :: !Int

  the number of characters preceding the match with -1 used if no text was captured by the RE (not even the empty string)

- captureLength :: !Int

  the number of chacter in the captured sub-string

#### Instances

Instances details

Functor Capture Source # |
Instance details Defined in Text.RE.ZeInternals.Types.Capture Methods fmap :: (a -> b) -> Capture a -> Capture b Source # (<$) :: a -> Capture b -> Capture a Source #
Show a => Show (Capture a) Source # |
Instance details Defined in Text.RE.ZeInternals.Types.Capture Methods showsPrec :: Int -> Capture a -> ShowS Source # show :: Capture a -> String Source # showList :: [Capture a] -> ShowS Source #
Eq a => Eq (Capture a) Source # |
Instance details Defined in Text.RE.ZeInternals.Types.Capture Methods (==) :: Capture a -> Capture a -> Bool Source # (/=) :: Capture a -> Capture a -> Bool Source #

hasCaptured :: Capture a -> Bool Source #

test if the capture has matched any text

capturePrefix :: Extract a => Capture a -> a Source #

returns the text preceding the match

captureSuffix :: Extract a => Capture a -> a Source #

returns the text after the match

# CaptureID

data CaptureID Source #

CaptureID identifies captures, either by number (e.g., [cp|1|]) or name (e.g., [cp|foo|]).

Constructors

IsCaptureOrdinal CaptureOrdinal |
IsCaptureName CaptureName |

#### Instances

Instances details

Show CaptureID Source # |
Instance details Defined in Text.RE.ZeInternals.Types.CaptureID Methods showsPrec :: Int -> CaptureID -> ShowS Source # show :: CaptureID -> String Source # showList :: [CaptureID] -> ShowS Source #
Eq CaptureID Source # |
Instance details Defined in Text.RE.ZeInternals.Types.CaptureID Methods (==) :: CaptureID -> CaptureID -> Bool Source # (/=) :: CaptureID -> CaptureID -> Bool Source #
Ord CaptureID Source # |

Instance details

Defined in Text.RE.ZeInternals.Types.CaptureID

Methods

compare :: CaptureID -> CaptureID -> Ordering Source #

(<) :: CaptureID -> CaptureID -> Bool Source #

(<=) :: CaptureID -> CaptureID -> Bool Source #

(>) :: CaptureID -> CaptureID -> Bool Source #

(>=) :: CaptureID -> CaptureID -> Bool Source #

max :: CaptureID -> CaptureID -> CaptureID Source #

min :: CaptureID -> CaptureID -> CaptureID Source #

type CaptureNames = HashMap CaptureName CaptureOrdinal Source #

the dictionary for named captures stored in compiled regular expressions associates

noCaptureNames :: CaptureNames Source #

an empty `CaptureNames` dictionary

newtype CaptureName Source #

a `CaptureName` is just the text of the name

Constructors

CaptureName |

Fields

- getCaptureName :: Text

#### Instances

Instances details

Show CaptureName Source # |
Instance details Defined in Text.RE.ZeInternals.Types.CaptureID Methods showsPrec :: Int -> CaptureName -> ShowS Source # show :: CaptureName -> String Source # showList :: [CaptureName] -> ShowS Source #
Eq CaptureName Source # |
Instance details Defined in Text.RE.ZeInternals.Types.CaptureID Methods (==) :: CaptureName -> CaptureName -> Bool Source # (/=) :: CaptureName -> CaptureName -> Bool Source #
Ord CaptureName Source # |

Instance details

Defined in Text.RE.ZeInternals.Types.CaptureID

Methods

compare :: CaptureName -> CaptureName -> Ordering Source #

(<) :: CaptureName -> CaptureName -> Bool Source #

(<=) :: CaptureName -> CaptureName -> Bool Source #

(>) :: CaptureName -> CaptureName -> Bool Source #

(>=) :: CaptureName -> CaptureName -> Bool Source #

max :: CaptureName -> CaptureName -> CaptureName Source #

min :: CaptureName -> CaptureName -> CaptureName Source #

Hashable CaptureName Source # |
Instance details Defined in Text.RE.ZeInternals.Types.CaptureID Methods hashWithSalt :: Int -> CaptureName -> Int Source # hash :: CaptureName -> Int Source #

newtype CaptureOrdinal Source #

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

Constructors

CaptureOrdinal |

Fields

- getCaptureOrdinal :: Int

#### Instances

Instances details

Enum CaptureOrdinal Source # |

Instance details

Defined in Text.RE.ZeInternals.Types.CaptureID

Methods

succ :: CaptureOrdinal -> CaptureOrdinal Source #

pred :: CaptureOrdinal -> CaptureOrdinal Source #

toEnum :: Int -> CaptureOrdinal Source #

fromEnum :: CaptureOrdinal -> Int Source #

enumFrom :: CaptureOrdinal -> [CaptureOrdinal] Source #

enumFromThen :: CaptureOrdinal -> CaptureOrdinal -> [CaptureOrdinal] Source #

enumFromTo :: CaptureOrdinal -> CaptureOrdinal -> [CaptureOrdinal] Source #

enumFromThenTo :: CaptureOrdinal -> CaptureOrdinal -> CaptureOrdinal -> [CaptureOrdinal] Source #

Ix CaptureOrdinal Source # |

Instance details

Defined in Text.RE.ZeInternals.Types.CaptureID

Methods

range :: (CaptureOrdinal, CaptureOrdinal) -> [CaptureOrdinal] Source #

index :: (CaptureOrdinal, CaptureOrdinal) -> CaptureOrdinal -> Int Source #

unsafeIndex :: (CaptureOrdinal, CaptureOrdinal) -> CaptureOrdinal -> Int Source #

inRange :: (CaptureOrdinal, CaptureOrdinal) -> CaptureOrdinal -> Bool Source #

rangeSize :: (CaptureOrdinal, CaptureOrdinal) -> Int Source #

unsafeRangeSize :: (CaptureOrdinal, CaptureOrdinal) -> Int Source #

Num CaptureOrdinal Source # |

Instance details

Defined in Text.RE.ZeInternals.Types.CaptureID

Methods

(+) :: CaptureOrdinal -> CaptureOrdinal -> CaptureOrdinal Source #

(-) :: CaptureOrdinal -> CaptureOrdinal -> CaptureOrdinal Source #

(*) :: CaptureOrdinal -> CaptureOrdinal -> CaptureOrdinal Source #

negate :: CaptureOrdinal -> CaptureOrdinal Source #

abs :: CaptureOrdinal -> CaptureOrdinal Source #

signum :: CaptureOrdinal -> CaptureOrdinal Source #

fromInteger :: Integer -> CaptureOrdinal Source #

Show CaptureOrdinal Source # |
Instance details Defined in Text.RE.ZeInternals.Types.CaptureID Methods showsPrec :: Int -> CaptureOrdinal -> ShowS Source # show :: CaptureOrdinal -> String Source # showList :: [CaptureOrdinal] -> ShowS Source #
Eq CaptureOrdinal Source # |
Instance details Defined in Text.RE.ZeInternals.Types.CaptureID Methods (==) :: CaptureOrdinal -> CaptureOrdinal -> Bool Source # (/=) :: CaptureOrdinal -> CaptureOrdinal -> Bool Source #
Ord CaptureOrdinal Source # |

Instance details

Defined in Text.RE.ZeInternals.Types.CaptureID

Methods

compare :: CaptureOrdinal -> CaptureOrdinal -> Ordering Source #

(<) :: CaptureOrdinal -> CaptureOrdinal -> Bool Source #

(<=) :: CaptureOrdinal -> CaptureOrdinal -> Bool Source #

(>) :: CaptureOrdinal -> CaptureOrdinal -> Bool Source #

(>=) :: CaptureOrdinal -> CaptureOrdinal -> Bool Source #

max :: CaptureOrdinal -> CaptureOrdinal -> CaptureOrdinal Source #

min :: CaptureOrdinal -> CaptureOrdinal -> CaptureOrdinal Source #

findCaptureID :: CaptureID -> CaptureNames -> Either String CaptureOrdinal Source #

look up a `CaptureID` in the `CaptureNames` dictionary

# Replace and ReplaceMethods

class (Show a, Eq a, Ord a, Extract a, Monoid a) => Replace a where Source #

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

Minimal complete definition

lengthR, packR, unpackR, linesR, unlinesR, parseTemplateR

Methods

lengthR :: a -> Int Source #

length function for a

packR :: String -> a Source #

inject String into a

unpackR :: a -> String Source #

project a onto a String

textifyR :: a -> Text Source #

inject into Text

detextifyR :: Text -> a Source #

project Text onto a

linesR :: a -> [a] Source #

split into lines

unlinesR :: [a] -> a Source #

concatenate a list of lines

appendNewlineR :: a -> a Source #

append a newline

substR :: (a -> a) -> Capture a -> a Source #

apply a substitution function to a Capture

parseTemplateR :: a -> Match a -> RELocation -> Capture a -> Maybe a Source #

convert a template containing $0, $1, etc., in the first argument, into a `phi` replacement function for use with replaceAllCaptures and replaceCaptures

#### Instances

Instances details

Replace ByteString Source # |

Instance details

Defined in Text.RE.ZeInternals.Replace

Methods

lengthR :: ByteString -> Int Source #

packR :: String -> ByteString Source #

unpackR :: ByteString -> String Source #

textifyR :: ByteString -> Text Source #

detextifyR :: Text -> ByteString Source #

linesR :: ByteString -> [ByteString] Source #

unlinesR :: [ByteString] -> ByteString Source #

appendNewlineR :: ByteString -> ByteString Source #

substR :: (ByteString -> ByteString) -> Capture ByteString -> ByteString Source #

parseTemplateR :: ByteString -> Match ByteString -> RELocation -> Capture ByteString -> Maybe ByteString Source #

Replace ByteString Source # |

Instance details

Defined in Text.RE.ZeInternals.Replace

Methods

lengthR :: ByteString -> Int Source #

packR :: String -> ByteString Source #

unpackR :: ByteString -> String Source #

textifyR :: ByteString -> Text Source #

detextifyR :: Text -> ByteString Source #

linesR :: ByteString -> [ByteString] Source #

unlinesR :: [ByteString] -> ByteString Source #

appendNewlineR :: ByteString -> ByteString Source #

substR :: (ByteString -> ByteString) -> Capture ByteString -> ByteString Source #

parseTemplateR :: ByteString -> Match ByteString -> RELocation -> Capture ByteString -> Maybe ByteString Source #

Replace Text Source # |

Instance details

Defined in Text.RE.ZeInternals.Replace

Methods

lengthR :: Text -> Int Source #

packR :: String -> Text Source #

unpackR :: Text -> String Source #

textifyR :: Text -> Text Source #

detextifyR :: Text -> Text Source #

linesR :: Text -> [Text] Source #

unlinesR :: [Text] -> Text Source #

appendNewlineR :: Text -> Text Source #

substR :: (Text -> Text) -> Capture Text -> Text Source #

parseTemplateR :: Text -> Match Text -> RELocation -> Capture Text -> Maybe Text Source #

Replace Text Source # |

Instance details

Defined in Text.RE.ZeInternals.Replace

Methods

lengthR :: Text -> Int Source #

packR :: String -> Text Source #

unpackR :: Text -> String Source #

textifyR :: Text -> Text Source #

detextifyR :: Text -> Text Source #

linesR :: Text -> [Text] Source #

unlinesR :: [Text] -> Text Source #

appendNewlineR :: Text -> Text Source #

substR :: (Text -> Text) -> Capture Text -> Text Source #

parseTemplateR :: Text -> Match Text -> RELocation -> Capture Text -> Maybe Text Source #

Replace (Seq Char) Source # |

Instance details

Defined in Text.RE.ZeInternals.Replace

Methods

lengthR :: Seq Char -> Int Source #

packR :: String -> Seq Char Source #

unpackR :: Seq Char -> String Source #

textifyR :: Seq Char -> Text Source #

detextifyR :: Text -> Seq Char Source #

linesR :: Seq Char -> [Seq Char] Source #

unlinesR :: [Seq Char] -> Seq Char Source #

appendNewlineR :: Seq Char -> Seq Char Source #

substR :: (Seq Char -> Seq Char) -> Capture (Seq Char) -> Seq Char Source #

parseTemplateR :: Seq Char -> Match (Seq Char) -> RELocation -> Capture (Seq Char) -> Maybe (Seq Char) Source #

Replace [Char] Source # |

Instance details

Defined in Text.RE.ZeInternals.Replace

Methods

lengthR :: [Char] -> Int Source #

packR :: String -> [Char] Source #

unpackR :: [Char] -> String Source #

textifyR :: [Char] -> Text Source #

detextifyR :: Text -> [Char] Source #

linesR :: [Char] -> [[Char]] Source #

unlinesR :: [[Char]] -> [Char] Source #

appendNewlineR :: [Char] -> [Char] Source #

substR :: ([Char] -> [Char]) -> Capture [Char] -> [Char] Source #

parseTemplateR :: [Char] -> Match [Char] -> RELocation -> Capture [Char] -> Maybe [Char] Source #

data ReplaceMethods a Source #

a selection of the Replace methods can be encapsulated with ReplaceMethods for the higher-order replacement functions

Constructors

ReplaceMethods |

Fields

- methodLength :: a -> Int
- methodSubst :: (a -> a) -> Capture a -> a

replaceMethods :: Replace a => ReplaceMethods a Source #

replaceMethods encapsulates ReplaceMethods a from a Replace a context