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

  • 2 types
  • 1 class
  • 4 values
  • Packageregex-1.1.0.2
  • Exports7
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceFind.lhs

Find

3 declarations

The Find toolkit traverses directory trees invoking actions for each file that matches a RE.

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

datadata FindMethods s
#

as we don't want the directory and FilePath dependencies we will abstract the three calls we need into this record type

Constructors

valuefindMatches_ :: IsRegex re s => FindMethods s -> re -> s -> IO [s]
#

recursively list all files whose filename matches given RE, sorting the list into ascending order; if the argument path has a trailing / then it will be removed

valuefindMatches_'
  1. :: IsRegex re s
  2. => FindMethods s

    the directory and filepath methods

  3. -> ([s] -> [s])

    result post-processing function

  4. -> (Match s -> Bool)

    filtering function

  5. -> re

    re to be matched against the leaf filename

  6. -> s

    root directory of the search

  7. -> IO [s]
#

recursively list all files whose filename matches given RE, using the given function to determine which matches to accept

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

Replace

0 declarations