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-base-0.94.0.3Haskell2010

Text.Regex.Base

Classes and instances for Regex matching.

This module merely imports and re-exports the common part of the new api: Text.Regex.Base.RegexLike and Text.Regex.Base.Context.

To see what result types the instances of RegexContext can produce, please read the Text.Regex.Base.Context haddock documentation.

This does not provide any of the backends, just the common interface they all use. The modules which provide the backends and their cabal packages are:

In fact, just importing one of the backends is adequate, you do not also need to import this module.

Example

The code

import Text.Regex.Base
import Text.Regex.Posix ((=~),(=~~)) -- or TDFA or PCRE or ...

main = do
    print b
    print c
    print d
  where
    b :: Bool
    b = ("abaca" =~ "(.)a")
    c :: [MatchArray]
    c = ("abaca" =~ "(.)a")
    d :: Maybe (String,String,String,[String])
    d = ("abaca" =~~ "(.)a")

will output

True
[array (0,1) [(0,(1,2)),(1,(1,1))],array (0,1) [(0,(3,2)),(1,(3,1))]]
Just ("a","ba","ca",["b"])
  • 1 value

RegexLike defines classes and type, and Extract instances