1
0
Fork
You've already forked pygnuregex
0
An implementation of the GNU interface to regex in Python
  • Python 68.1%
  • C 30.9%
  • Makefile 1%
2025年05月15日 01:11:59 -04:00
src/pygnuregex always specify argtypes for C functions that take arguments 2025年05月15日 01:05:32 -04:00
tests first commit 2025年04月17日 04:23:46 -04:00
.gitignore first commit 2025年04月17日 04:23:46 -04:00
COPYING first commit 2025年04月17日 04:23:46 -04:00
Makefile first commit 2025年04月17日 04:23:46 -04:00
MANIFEST.in first commit 2025年04月17日 04:23:46 -04:00
pyproject.toml always specify argtypes for C functions that take arguments 2025年05月15日 01:05:32 -04:00
README.md update readme 2025年05月15日 01:11:59 -04:00
setup.py first commit 2025年04月17日 04:23:46 -04:00
THANKS always specify argtypes for C functions that take arguments 2025年05月15日 01:05:32 -04:00

Pygnuregex, GNU regex for Python

Pygnuregex is a Python package for the GNU interface of regex functions in <regex.h>. The GNU interface provides a wide range of different syntaxes for the regex compiler. This package requires GNU libc to work properly.

Example

import pygnuregex
# Search for the first match
p = pygnuregex.compile(b"f\\(oo\\)[0-9]+")
result = p.search(b"hello foo123!") # ==> 6
p.span() # ==> [(6, 12), (7, 9)]
# All matches
p = pygnuregex.compile(b"\\(foo\\|bar\\)[0-9]+")
list(p.finditer(b"hello foo123 and bar456!"))
# ==> [[(6, 12), (6, 9)],[(17, 23), (17, 20)]]

The SyntaxFlag enum contains all the available syntax options that may be set in pygnuregex.compile().