regex
Alternative regular expression module, to replace re.
Decision gist · record as of 2026-08-14
Yes. The regex module is actively maintained, production-stable, has no security vulnerabilities, and carries permissive dual licensing. Install friction is moderate but manageable with pre-built wheels for all major platforms. It is worth installing if you need advanced regex features (nested sets, fuzzy matching, full Unicode support) or are already using re and want a drop-in replacement with extended capabilities. For standard regex tasks, the built-in re module remains adequate.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Targeted at CPython; behavior with PyPy is undefined for non-ASCII strings due to UTF-8 storage differences.
- Medium install friction due to compiled wheels for multiple platforms and Python versions.
License · maintenance · safety
Apache-2.0 AND CNRI-Python (permissive) — Dual-licensed under Apache-2.0 and CNRI-Python (permissive). Both licenses allow commercial and private use with minimal restrictions, making this safe for most projects.
last release 2026-07-19 (26 days) · last repo commit 2026-08-12 · 594 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 437,721,689 downloads/mo, #94 on PyPI
Alternatives
Verify before relying
import regex
# Basic usage (compatible with re module)
match = regex.search(r'\d+', 'abc123')
print(match.group())
# Advanced: nested sets (Version 1 behavior)
match = regex.search(r'[[a-z]--[aeiou]]', 'xyz', regex.VERSION1)
print(match.group())- Performance comparison with standard re module for typical workloads
- Maturity and adoption rate among projects currently using re
- Specific use cases where fuzzy matching and POSIX matching provide measurable value
What it is and what it does
The regex module is a production-ready alternative to Python's built-in `re` module that extends regex capabilities while maintaining full backward compatibility. It supports Unicode 17.0.0, offers both simple and full case-folding, and introduces advanced features like nested sets with set operations, fuzzy matching with best-match and enhanced-match modes, POSIX leftmost-longest matching, and lookaround in conditional patterns. The module has zero runtime dependencies and releases the GIL during matching on immutable strings, enabling concurrent thread execution.
It provides two behavior modes: Version 0 (compatible with the standard re module) and Version 1 (with enhanced features like nested sets and improved zero-width match handling). Scoped flags can apply to parts of a pattern and be toggled on/off, while global flags apply to the entire pattern. The package is actively maintained, supports modern Python versions (3.10–3.14), and has no known security vulnerabilities.
Use it for
- Replace re in projects needing nested character classes or set operations like `[[a-z]--[aeiou]]` for complex character exclusions
- Text processing pipelines requiring full Unicode case-folding for accurate multilingual case-insensitive matching
- Pattern matching tasks where POSIX leftmost-longest semantics are required instead of standard greedy/backtracking behavior
- Fuzzy regex matching to find approximate patterns or improve match quality with BESTMATCH or ENHANCEMATCH flags
- Multithreaded applications where concurrent regex matching on immutable strings improves throughput via GIL release
- Conditional patterns with lookahead/lookbehind tests for context-dependent matching logic
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
The regex module is actively maintained, production-stable, has no security vulnerabilities, and carries permissive dual licensing. Install friction is moderate but manageable with pre-built wheels for all major platforms. It is worth installing if you need advanced regex features (nested sets, fuzzy matching, full Unicode support) or are already using re and want a drop-in replacement with extended capabilities. For standard regex tasks, the built-in re module remains adequate.
Install
regex on PyPI
Before you install
Medium install friction due to compiled wheels for multiple platforms and Python versions. Package is actively maintained with a recent release (26 days ago) and shows healthy repository activity (594 stars, last commit 2026-08-12). Supports current Python versions (3.10–3.14).
Requires Python 3.10 or later. Targeted at CPython; behavior with PyPy is undefined for non-ASCII strings due to UTF-8 storage differences.
License in practice
Dual-licensed under Apache-2.0 and CNRI-Python (permissive). Both licenses allow commercial and private use with minimal restrictions, making this safe for most projects.
Quickstart
import regex
# Basic usage (compatible with re module)
match = regex.search(r'\d+', 'abc123')
print(match.group())
# Advanced: nested sets (Version 1 behavior)
match = regex.search(r'[[a-z]--[aeiou]]', 'xyz', regex.VERSION1)
print(match.group())
Verify before relying
- Performance comparison with standard re module for typical workloads
- Maturity and adoption rate among projects currently using re
- Specific use cases where fuzzy matching and POSIX matching provide measurable value
Package facts
| License | Apache-2.0 AND CNRI-Python permissive |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | None |
| Maintenance | Actively maintained 26 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 437,721,689 / month, #94 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/Engineering :: Information AnalysisTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text ProcessingTopic :: Text Processing :: General |
Evidence: regex-2026.7.19-cp310-cp310-macosx_10_9_universal2.whl; regex-2026.7.19-cp310-cp310-macosx_10_9_x86_64.whl; regex-2026.7.19-cp310-cp310-macosx_11_0_arm64.whl; regex-2026.7.19-cp310-cp310-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; regex-2026.7.19-cp310-cp310-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl; regex-2026.7.19-cp310-cp310-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl; regex-2026.7.19-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; regex-2026.7.19-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; regex-2026.7.19-cp310-cp310-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl; regex-2026.7.19-cp310-cp310-musllinux_1_2_aarch64.whl; regex-2026.7.19-cp310-cp310-musllinux_1_2_ppc64le.whl; regex-2026.7.19-cp310-cp310-musllinux_1_2_riscv64.whl; regex-2026.7.19-cp310-cp310-musllinux_1_2_s390x.whl; regex-2026.7.19-cp310-cp310-musllinux_1_2_x86_64.whl; regex-2026.7.19-cp310-cp310-win32.whl; regex-2026.7.19-cp310-cp310-win_amd64.whl; regex-2026.7.19-cp310-cp310-win_arm64.whl; regex-2026.7.19-cp311-cp311-macosx_10_9_universal2.whl; regex-2026.7.19-cp311-cp311-macosx_10_9_x86_64.whl; regex-2026.7.19-cp311-cp311-macosx_11_0_arm64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “nested regex sets”
- regexA drop-in replacement for Python's standard `re` module that adds…
- zhonZhon provides character constants and regular expression patterns for…
- rstrGenerates random strings from custom alphabets, predefined character…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also onigurumacffi · real-regex · rebulk · backrefs · repath · google-re2 · exrex · match · greenery · ripgrepy