greenery
Greenery allows manipulation of regular expressions
Decision gist · record as of 2026-08-14
Yes, if you need to reason about regular expressions as formal languages—computing intersections, complements, or equivalences. The library is stable, has no dependencies, and carries a permissive license. However, it is aging (no release since 2024-06-08); install it for a specific regex-algebra task, but do not expect active maintenance or rapid updates.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with no runtime dependencies.
- Maintenance status is aging—last commit was 2025-09-20 but the package has not had a release since 2024-06-08, suggesting the project is stable but not actively developed.
License · maintenance · safety
MIT License (permissive) — MIT License (permissive) means you can use, modify, and distribute greenery freely in commercial and private projects with minimal restrictions, provided you include the license notice.
last release 2024-06-08 (797 days) · last repo commit 2025-09-20 · 399 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 250,525 downloads/mo, #8,627 on PyPI
Alternatives
Verify before relying
pip install greenery
from greenery import parse
# Compute intersection of two regexes
result = parse("abc...") & parse("...def")
print(result) # "abcdef"- Whether the package works with Python versions beyond 3.8, given the classifier lists only 3.8 and requires_python is unspecified.
- Performance characteristics when working with complex or deeply nested regular expressions.
What it is and what it does
Greenery is a library for parsing and manipulating regular expressions at the language level—not for matching strings, but for reasoning about the patterns themselves. It converts regexes to finite state machines internally, allowing you to perform set operations like intersection, union, difference, and complement on regex patterns. The core use case is computing the intersection of two regular expressions: the set of strings that both patterns accept, returned as a new regex.
The library supports standard regex syntax (character classes, quantifiers, alternation, grouping) but intentionally omits anchors (^ and $), backreferences, and lookahead/lookbehind constructs, since these fall outside formal regular language theory. It provides a Pattern API with methods modeled on frozenset, plus regex-specific operations like reversal, derivation (Brzozowski derivative), and reduction (simplification heuristics). With no external dependencies and a permissive MIT license, it's lightweight and suitable for embedding in tools that need to reason about regex patterns.
Use it for
- Find the common strings accepted by two regex patterns by computing their intersection.
- Simplify complex regular expressions using the reduce() method to apply algebraic simplification heuristics.
- Reverse a regex pattern to match reversed strings, useful in bidirectional text processing.
- Test regex equivalence by comparing two patterns to verify they match exactly the same set of strings.
- Generate all strings matched by a regex using the strings() generator, for validation or testing.
- Compute the complement of a regex (everythingbut) to match all strings not accepted by the original pattern.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to reason about regular expressions as formal languages—computing intersections, complements, or equivalences.
The library is stable, has no dependencies, and carries a permissive license. However, it is aging (no release since 2024-06-08); install it for a specific regex-algebra task, but do not expect active maintenance or rapid updates.
Install
greenery on PyPI
Before you install
Low install friction with no runtime dependencies. Maintenance status is aging—last commit was 2025-09-20 but the package has not had a release since 2024-06-08, suggesting the project is stable but not actively developed.
License in practice
MIT License (permissive) means you can use, modify, and distribute greenery freely in commercial and private projects with minimal restrictions, provided you include the license notice.
Quickstart
pip install greenery
from greenery import parse
# Compute intersection of two regexes
result = parse("abc...") & parse("...def")
print(result) # "abcdef"
Verify before relying
- Whether the package works with Python versions beyond 3.8, given the classifier lists only 3.8 and requires_python is unspecified.
- Performance characteristics when working with complex or deeply nested regular expressions.
Package facts
| License | MIT License permissive |
| Python support | Not specified |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Aging 797 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 250,525 / month, #8,627 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3.8 |
Evidence: greenery-4.2.2-py3-none-any.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 › “regex intersection computation”
- greeneryParses and manipulates regular expressions by converting them to…
- interegularInteregular checks whether pairs of Python regular expressions can…
- cmeel-qhullProvides precompiled qhull binaries (convex hull, Delaunay…
Give your agent the search over MCP, or paste the wish link into any chat.
More Text Processing packages
A drop-in replacement for Python's standard `re` module that adds advanced regex features like nested sets, fuzzy matching, lookaround in conditionals, and full Unicode case-folding while maintaining backward compatibility.
pyparsing provides a library for building text parsers directly in Python code using composable grammar classes, handling quoted strings, whitespace variation, and embedded comments without regex or lex/yacc.
Install it if you need to parse text or define grammars programmatically.
fonttools manipulates font files in multiple formats (TrueType, OpenType, AFM, Type 1, Mac-specific) and includes TTX, a tool to convert fonts to and from XML text format.
Install it if you need to read, write, or manipulate fonts programmatically or via the TTX command-line tool.
Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.
RapidFuzz provides fast fuzzy string matching using Levenshtein Distance and related metrics, implemented mostly in C++ with Python bindings for rapid similarity scoring and approximate string matching.
Install it if you need fuzzy string matching; it's a solid replacement for FuzzyWuzzy with better licensing and performance.
tinycss2 parses CSS strings into token and block objects, and generates CSS strings from those objects, following the CSS Syntax Level 3 specification without enforcing specific properties or values.
Install it if your project requires CSS tokenization or syntax manipulation.
See also interegular · regexploit · repath · exrex · iregexp-check · retrie · suffix-trees · flpc · tag-expressions