HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Moduleregex-1.1.0.2Haskell2010

Text.RE.Tools.Find

Contents
  1. Find
  2. IsRegex
  3. Replace
Synopsis
  • Packageregex-1.1.0.2
  • Exports7
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceFind.lhs

Find

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

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

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