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

Safe HaskellNone
LanguageHaskell2010

Hledger.Utils.Regex

Contents

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

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.

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

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