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 search 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.
p = pycregex.compile(b"f\\(oo\\)", nmatch=2)
p.search(b"foo") # ==> 0
p.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-2.0.3.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pycregex-2.0.3.tar.gz
Algorithm Hash digest
SHA256 b2207b47ada397380bc284752e82adc6c446763c4f7ba594f4a22c5b6b6a0d7d
MD5 f608450da871df150267a7707ddad41b
BLAKE2b-256 842abd8c8318d3734f082755ecce7a288cd6a5e5f51a7d4f15f9911aba5f48e4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycregex-2.0.3-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-2.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5037bc88db06ee67b962667ffd59b22bc86a6930a5e8bc5bc1e07bffd7f8be2b
MD5 f2f77ff522fc01511be521d9071dfb86
BLAKE2b-256 bc815b0a973ff52171db0011e5dbbd95772ff9475c0f8c52a83d1007d78b4d2c

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