hledger-lib-0.26: Core data types, parsers and utilities for the hledger accounting tool.

Safe Haskell | None
Language | Haskell2010

Hledger.Utils.Regex

Contents

- type aliases
- standard regex operations

Description

Easy regular expression helpers, currently based on regex-tdfa. These should:

- be cross-platform, not requiring C libraries
- support unicode
- support extended regular expressions
- support replacement, with backreferences etc.
- support splitting
- have mnemonic names
- have simple monomorphic types
- work with strings

Current limitations:

- (?i) and similar are not supported

Synopsis

- type Regexp = String
- type Replacement = String
- regexMatches :: Regexp -> String -> Bool
- regexMatchesCI :: Regexp -> String -> Bool
- regexReplace :: Regexp -> Replacement -> String -> String
- regexReplaceCI :: Regexp -> Replacement -> String -> String
- regexReplaceBy :: Regexp -> (String -> String) -> String -> String
- regexReplaceByCI :: Regexp -> (String -> String) -> String -> String

# type aliases

type Regexp = String Source

Regular expression. Extended regular expression-ish syntax ? But does not support eg (?i) syntax.

type Replacement = String Source

A replacement pattern. May include numeric backreferences (N).

# standard regex operations

regexMatches :: Regexp -> String -> Bool Source

regexMatchesCI :: Regexp -> String -> Bool Source

regexReplace :: Regexp -> Replacement -> String -> String Source

Replace all occurrences of the regexp with the replacement pattern. The replacement pattern supports numeric backreferences (N) but no other RE syntax.

regexReplaceCI :: Regexp -> Replacement -> String -> String Source

regexReplaceBy :: Regexp -> (String -> String) -> String -> String Source

Replace all occurrences of the regexp, transforming each match with the given function.

regexReplaceByCI :: Regexp -> (String -> String) -> String -> String Source