HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Moduleregex-1.1.0.2Haskell2010

Text.RE.Tools.Grep

  • 5 types
  • 1 class
  • 11 values
  • Packageregex-1.1.0.2
  • Exports17
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceGrep.lhs

The Grep toolkit matches REs against each line of a text.

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

valuegrepFilter :: IsRegex re s => re -> s -> [Line s]
#

returns a Line for each line in the argument text, enumerating all of the matches for that line

typetype GrepScript re s t = [(re, LineNo -> Matches s -> Maybe t)]
#

a GrepScript lists RE-action associations, with the first RE to match a line selecting the action to be executed on each line in the file

IsRegex

4 declarations
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|]

LineNo

4 declarations

Replace

0 declarations