A more readable alternative to regular expressions.
Project description
Regexable
Regexable is a Python package that simplifies the creation and management of regular expressions through an intuitive, chainable interface. This package makes it easier for both beginners and experienced developers to construct complex regex patterns in a more readable and maintainable way.
Documentation
The official documentation is available at Regexable Documentation.
Features
- Chainable Methods: Build regex patterns step by step using a clean, chainable syntax.
- Anchors and Boundaries: Easily add start-of-line, end-of-line, word boundary, and other anchors to your patterns.
- Text Matching: Add specific text or optional text segments, and define characters to match or exclude.
- Quantifiers: Specify how many times a character or group should be matched (e.g., zero or more, one or more, exactly n times).
- Modifiers: Apply flags for case-insensitive or multiline matching.
- Grouping and Alternation: Group patterns together or create alternatives using the
groupandor_methods. - Utilities: Match, search, and compile patterns into regex objects.
Installation
Install Regexable via pip:
pip install regexable
Quick Start
Here's a quick example of how to use Regexable:
from regexable import Regexable
# Construct a regex pattern
pattern = Regexable()\
.start_of_line()\
.then("Hello")\
.whitespace()\
.one_or_more()\
.then("World")\
.end_of_line()\
.build()
# Match a string
match = pattern.match("Hello World")
print(match) # Output: <re.Match object; span=(0, 11), match='Hello World'>
# Check if a string matches the pattern
if pattern.match("Hello World"):
print("Match found!")
# Use additional features
regex = Regexable()\
.start_of_line()\
.then("abc")\
.maybe("def")\
.anything_but("g")\
.end_of_line()\
.build()
print(regex.pattern) # Output: ^abc(def)?[^g]+$
Contributing
We welcome contributions! If you find a bug or have a feature request, please create an issue on our GitHub repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file regexable-0.1.1.tar.gz.
File metadata
- Download URL: regexable-0.1.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5f0d1ec351b078395b8f7142260842e79fa16967b99c90461a87d0be167b150
|
|
| MD5 |
fe26e02c103155cc7fb50723491f3552
|
|
| BLAKE2b-256 |
84f9a15be644c2e93a31d9f6f96e7bcf1cec5771c1c220bfede48e555176de6b
|
File details
Details for the file regexable-0.1.1-py3-none-any.whl.
File metadata
- Download URL: regexable-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1e19cc7866544726b8ebfca4f7c2f86893ee83bf85c11b43f254bf82a7bce64
|
|
| MD5 |
efa8175f2bbc9f8ae6e4d446f227cfc2
|
|
| BLAKE2b-256 |
1cb5a9a930e524faa894d191c8c6078d9342c4459566293b46a0e85338c0641f
|