An implementation of the GNU interface to regex in Python
| src/pygnuregex | always specify argtypes for C functions that take arguments | |
| tests | first commit | |
| .gitignore | first commit | |
| COPYING | first commit | |
| Makefile | first commit | |
| MANIFEST.in | first commit | |
| pyproject.toml | always specify argtypes for C functions that take arguments | |
| README.md | update readme | |
| setup.py | first commit | |
| THANKS | always specify argtypes for C functions that take arguments | |
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().