Registry / serialization / onigurumacffi

onigurumacffi

JSON →
library1.5.0pypypi✓ verified 83d ago

Onigurumacffi provides Python cffi bindings for the Oniguruma regex engine. Currently at version 1.5.0, it wraps the Oniguruma C library, offering a performant, multibyte-aware regex engine that operates primarily on bytes, distinct from Python's built-in `re` module. The library bundles the Oniguruma C source, simplifying installation, and requires Python 3.10 or newer. Releases are infrequent, tied to updates in the underlying Oniguruma library or CFFI.

pip install onigurumacffi
INSTALL
IMPORT
SIG · ONIGURUMACFFI
O
onigurumacffi
serializationpythonv1.5.0
Install
1.9s avg
Import
Disk
20MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
build_error
glibc
py 3.103.910 runs
installs and imports cleanly · install 1.9s · import 0.000s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

re
from onigurumacffi import re
from onigurumacffi import OnigurumaRegex
compile
from onigurumacffi import compile
OnigError
from onigurumacffi import OnigError

This quickstart demonstrates how to initialize `OnigurumaRegex` with a byte pattern and encoding, perform `match` and `search` operations on byte strings, and access matched groups. It also includes basic error handling for invalid regex patterns.

from onigurumacffi import OnigurumaRegex, OnigurumaMatch, OnigurumaError # Create a regex object. Oniguruma supports various encodings, UTF-8 is common. # Patterns are typically bytes for direct Oniguruma interaction. regex = OnigurumaRegex(b'^(hello|hi)\\s+(world|there)!$', encoding='utf-8') # Match a string (also bytes) text = b'hello world!' match: OnigurumaMatch | None = regex.match(text) if match: print(f"Match found!") print(f"Full match: {match.group(0).decode('utf-8')}") print(f"Group 1: {match.group(1).decode('utf-8')}") print(f"Group 2: {match.group(2).decode('utf-8')}") else: print(f"No match for '{text.decode('utf-8')}'") # Example of a search (finding a substring match) search_text = b'some hello world! text' search_match: OnigurumaMatch | None = regex.search(search_text, start=0) if search_match: print(f"\nSearch found!") print(f"Search match: {search_match.group(0).decode('utf-8')}") # Error handling try: invalid_regex = OnigurumaRegex(b'[invalid') except OnigurumaError as e: print(f"\nCaught expected error: {e}")
Debug
Known issues
gotchaOnigurumacffi uses the Oniguruma regex engine, which has different syntax and behavior compared to Python's built-in `re` module. Features, character classes, and performance characteristics will differ.
fix
Always refer to Oniguruma's official documentation for pattern syntax and behavior. Do not assume `re` module compatibility.
affects: All versions
gotchaThe `onigurumacffi` library statically links against a specific version of the Oniguruma C library (e.g., 6.9.8). If you need features or bug fixes from a newer Oniguruma C version, you might need to wait for a new `onigurumacffi` release or compile it yourself.
fix
Check the `onigurumacffi` GitHub README for the bundled Oniguruma version. For newer versions, monitor `onigurumacffi` releases or consider custom compilation.
affects: All versions
gotchaOniguruma primarily operates on bytes, not Python strings. Patterns and input text passed to `OnigurumaRegex` methods must be `bytes` objects. While an `encoding` parameter is provided, direct byte handling is often necessary.
fix
Ensure all patterns and input strings are encoded to `bytes` (e.g., `b'pattern'` or `'string'.encode('utf-8')`) before passing them to `onigurumacffi` functions. Decode results (e.g., `match.group(1).decode('utf-8')`) for string output.
affects: All versions
Upgrade
Version history
1.5.0latest on PyPI · released Jan 25, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
onigurumacffi — pip install onigurumacffi · libregistry