pregexp:
Portable Regular Expressions
for Scheme and Common Lisp

 Download 

 Dorai Sitaram 

pregexp.scm is a portable library for regular expressions (aka regexps or regexes) that runs in any Scheme that complies with R4RS, R5RS or R6RS [2]. It provides regular expressions modeled on Perl’s [13], and includes such powerful directives as numeric and nongreedy quantifiers, capturing and non-capturing clustering, POSIX character classes, selective case- and space-insensitivity, backreferences, alternation, backtrack pruning, positive and negative lookahead and lookbehind, in addition to the more basic directives familiar to all regexp users.

To use, simply load the file pregexp.scm into your Scheme. (Alternatively, if your dialect allows it, you can install pregexp as a module — consult the file INSTALL in the distribution.)

The file pregexp.lisp is the Common Lisp version of this library. To use it, load it into your Common Lisp. (The descriptions and examples in this manual use Scheme syntax, but their translation to CL syntax is trivial.)

Contents

    1  Introduction

    2  Regexp procedures
        2.1  pregexp
        2.2  pregexp‑match‑positions
        2.3  pregexp‑match
        2.4  pregexp‑split
        2.5  pregexp‑replace
        2.6  pregexp‑replace*
        2.7  pregexp‑quote

    3  The regexp pattern language
        3.1  Basic assertions
        3.2  Characters and character classes
            3.2.1  Some frequently used character classes
            3.2.2  POSIX character classes
        3.3  Quantifiers
            3.3.1  Numeric quantifiers
            3.3.2  Non-greedy quantifiers
        3.4  Clusters
            3.4.1  Backreferences
            3.4.2  Non-capturing clusters
            3.4.3  Cloisters
        3.5  Alternation
        3.6  Backtracking
            3.6.1  Disabling backtracking
        3.7  Looking ahead and behind
            3.7.1  Lookahead
            3.7.2  Lookbehind

    4  An extended example

    5  References

Last modified: Fri, Jan 30, 2020, 2:29 pm UTC−5