HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleregex-1.1.0.2Haskell2010

Text.RE.Tools.IsRegex

  • 1 type
  • 1 class
  • 2 values
  • Packageregex-1.1.0.2
  • Exports4
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceIsRegex.lhs

IsRegex

4 declarations

The IsRegex class abstracts over each regex back end and the text types they support allowing general regex tools to constructed.

See the Regex Tools tutorial at http://re-tutorial-tools.regex.uk

classclass Replace s => IsRegex re s where
#

the IsRegex class allows polymorhic tools to be written that will work with a variety of regex back ends and text types

Methods

Instances6IsRegex
datadata SearchReplace re s
#

contains a compiled RE and replacement template

Constructors

  • SearchReplace
    • getSearch :: !re

      the RE to match a string to replace

    • getTemplate :: !s

      the replacement template with ${cap} used to identify a capture (by number or name if one was given) and $$ being used to escape a single $

Instances2Functor, Show
valuesearchReplaceAll :: IsRegex re s => SearchReplace re s -> s -> s
#

search and replace all matches in the argument text; e.g., this function will convert every YYYY-MM-DD format date in its argument text into a DD/MM/YYYY date:

searchReplaceAll [ed|${y}([0-9]{4})-0*${m}([0-9]{2})-0*${d}([0-9]{2})///${d}/${m}/${y}|]
valuesearchReplaceFirst :: IsRegex re s => SearchReplace re s -> s -> s
#

search and replace the first occurrence only (if any) in the input text e.g., to prefix the first string of four hex digits in the imput text, if any, with 0x:

searchReplaceFirst [ed|[0-9A-Fa-f]{4}///0x$0|]