Fetching contributors…
Cannot retrieve contributors at this time
164 lines (114 sloc) 5.43 KB


A Regular Expression Toolkit for regex-base

regex extends regex-base with:

  • a text-replacement toolkit
  • special datatypes for many matches, first match and individual captures
  • compile-time checking of RE syntax
  • a unified means of controlling case-sensitivity and multi-line options
  • high-level AWK-like tools for building text processing apps
  • the option of using match operators with reduced polymorphism on the text and/or result types
  • regular expression macros including
    • a number of useful RE macros
    • a test bench for testing and documenting new macro environments
  • built-in support for the TDFA and PCRE back ends
  • comprehensive documentation and copious examples

Road Map

  ☑ 2017-01-26  Pre-release (I)
  ☑ 2017-01-30  Pre-release (II)
  ☐ 2017-02-06  RFC
  ☐ 2017-02-20  a candidate stable release
  ☐ 2017-03-20  first stable release

Helping Out

If you have any feedback or suggestion then please drop me a line.

    t: @cdornan

The Builds

Hackage BSD3 License Un*x build Windows build Coverage

For details of the current release and the build pipelines see the Build Status page.

Installation Instructions


cabal update && cabal install regex


stack install regex

Loading up the Tutorial into ghci

First unpack the source distribution.

cabal unpack regex
cd regex-*

Loading the tutorial into ghci with cabal:

cabal configure
cabal repl re-tutorial

Loading the tutorial into ghci with stack:

stack --stack-yaml stack-8.0.yaml exec ghci -- -ghci-script lib/ghci examples/re-tutorial.lhs

Table of Contents

The Tutorial, Tests and Examples

The Tutorial examples/re-tutorial.lhs

provides an introduction to the package with simple examples that you can try out in your favourite Haskell REPL and references to examples in the example programs and library code.

The Log Processor Example examples/re-nginx-log-processor.lhs

provides an extended example of large-scale RE development with the regex test bench.

The Include Processor Example examples/re-include.lhs

is the starting point for the preprocessor that we use to generate the tutorial HTML and its derived test suite.

The Cabal Processor Example examples/re-gen-cabals.lhs

is the Sed preprocessor we use to generate our cabal file from the template in lib/regex-master.cabal.

The Library Tests examples/re-tests.lhs

contains various test suites for exercising various components of the library.

The Tutorial Preprocessor examples/re-prep.lhs

contains the tool we use to generate the tutorial HTML and its derived test suite.

The API Module Generator examples/re-gen-modules.lhs

contains a tool for generating the parts of the API that can be easily synthesized from a seed/master module.

Selected Library Modules

Some of the library modules have been prepared as literate programs for easy browsing of their underlying source code.


contains the definitions of the Matches, Match and Capture data types (with helpers) that form the foundations for everything else.


contains the text-replacement toolkit.


contains the Options types for controlling RE parsing and compilation.


contains the IsRegex class for writing polymorphic regex tools that work with all regex back ends and text type combinations.


contains the test bench used to build the standard macro environment and can be used for developing other macro environments with test and documentation.


contains the polymorphic editing toolkit used by Text.RE.Tools.Sed.


contains the Sed tool for building awk-like text processors.


contains a simple grep tool for extracting lines that match a RE from a file.


contains a simple scanning tool for building prototype scanners before being discarded or converted into Alex scanners.


is an internal library module for dealing with named captures in REs.