Skip to main content

No project description provided

Project description

# Regular expressions made readable

## Introduction

bourbaki.regex provides an interface for constructing arbitrarily complex regular expressions using standard Python syntax.

The goals of the package are the following:

  • allow the user to be as terse as possible while not sacrificing readability

  • support the full range of constructs available in the standard library regex engine (re module)

  • be extensible and modular to support more advanced constructs in the future, as for instance provided by the regex module

  • handle minutiae such as handling backreferences (inferring the correct group index)

  • raise meaningful errors at compile time, such as named group collisions, nonexistent backreferences, and lookbehind assertions that are not fixed-length.

## Usage

There are a few base constructors from which all expression patterns can be built:

  • bourbaki.regex.C: Character class constructor. C[‘a’:’z’, ‘A-Z’, ‘0’:’9’] for instance is equivalent to the raw regular expression r’[a-zA-Z0-9]

  • bourbaki.regex.L/Literal: Literal string match. This handles escaping special characters that are reserved for regular expression syntax. For example L(‘*foo[bar]*’) is equivalent to the raw regular expression r’*foo[bar]*’ (note the ‘' escapes)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bourbaki.regex-0.1.0.tar.gz (10.8 kB view hashes)

Uploaded Source

Built Distribution

bourbaki.regex-0.1.0-py3-none-any.whl (15.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page