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

regex

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  0.0.0.1  Pre-release (I)
  ☑ 2017-01-30  0.0.0.2  Pre-release (II)
  ☐ 2017-02-06  0.0.1.0  RFC
  ☐ 2017-02-20  0.1.0.0  a candidate stable release
  ☐ 2017-03-20  1.0.0.0  first stable release

Helping Out

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

    t: @cdornan
    e: chris.dornan@irisconnect.co.uk
    w: https://github.com/iconnect/regex/issues

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

Either

cabal update && cabal install regex

or

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.

Text.RE.Capture

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

Text.RE.Replace

contains the text-replacement toolkit.

Text.RE.Options

contains the Options types for controlling RE parsing and compilation.

Text.RE.IsRegex

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

Text.RE.TestBench

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

Text.RE.Edit

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

Text.RE.Tools.Sed

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

Text.RE.Tools.Grep

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

Text.RE.Tools.Lex

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

Text.RE.Internal.NamedCaptures

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