Skip to main content

An implementation of GNU libc regex in Python

Project description

Pycregex, C-style POSIX BRE (and ERE) syntax regex for Python

This package brings libc's <regex.h> API to Python. While Python has re and there's the regex package, they do not have the syntax of <regex.h>. The simplest example is the regex pattern f\(oo\) which is not supported by either of the mentioned packages, because neither supports escaping the parentheses. The syntax of <regex.h> is specified in POSIX, see the Base Specification v8 Regular Expressions chapter.

This is not a glorious API, but if you need it, here it is.

Example

We match with subgroups, and show how the subgroup begin/end indices are accessed.

import pycregex
# Note that this package only works with binary strings. nmatch is
# number of groups plus one because we must include the entire match.
r = pycregex.compile(b"f\\(oo\\)", nmatch=2)
r.match(b"foo") # ==> 0
r.span() # ==> [(0, 3), (1, 3)]

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

pycregex-1.0.0.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycregex-1.0.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file pycregex-1.0.0.tar.gz.

File metadata

  • Download URL: pycregex-1.0.0.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for pycregex-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9a7004b96740d2a88cb5447c17a3350eabac3f825fccd5451c1067dd036e4d92
MD5 6bb167355e4eab703882c0cc1b575cb4
BLAKE2b-256 830b8e1d3707f8fa417d98c1dfaca2613a77358450e82fb63118637db5fc1a3f

See more details on using hashes here.

File details

Details for the file pycregex-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pycregex-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for pycregex-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 945452b00cb62c61f9585c33ce4ad81f507e5be2dd88690a93a1c11138927169
MD5 e29e8103d2c540afb84011f6a0dffed5
BLAKE2b-256 20baa4f6e6d2b1eb120998fd07a12b4c228ddd6d881aa5cb32d9d3b40b308463

See more details on using hashes here.

Supported by

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