py-incl-excl-regex
Regex-based inclusion/exclusion filter for Python.
Install
pip install py-incl-excl-regex
Quick start
from incl_excl_regex import PatternFilter
f = PatternFilter(
include=[r"sg\.gov\.sla"],
exclude=[r"\.to(\.|$)", r"\.dao(\.|$)"],
)
f.matches("sg.gov.sla.stars.service.FooService") # True
f.matches("sg.gov.sla.stars.to.FooTo") # False — excluded
f.matches("com.example.Bar") # False — not included
Filter rules
- Include list: a value must match at least one include pattern to pass. Omitting include patterns accepts everything.
- Exclude list: a value must not match any exclude pattern.
- Exclude wins: if a value matches both an include and an exclude pattern, it is rejected.
- Patterns are matched with
re.search— the pattern can match anywhere in the string.
Loading from a JSON file
f = PatternFilter.from_file("filter.json")
Expected JSON shape (both keys are optional):
{
"include": ["sg\\.gov\\.sla"],
"exclude": ["\\.to(\\.|$)", "\\.dao(\\.|$)"]
}
Anchoring
Patterns use re.search, so they match anywhere in the string by default. Use ^ and $ anchors when you need to match from the start or end:
PatternFilter(include=[r"^sg\.gov\.sla"]) # must start with sg.gov.sla
PatternFilter(exclude=[r"\.to$"]) # only rejects strings ending in .to
Metadata
Release files for py-incl-excl-regex 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_incl_excl_regex-0.1.0.tar.gz | 12.5 kB | Without provenance | Details for py_incl_excl_regex-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_incl_excl_regex-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for py_incl_excl_regex-0.1.0-py3-none-any.whl |
Total release size: 16.4 kB
Release files / py_incl_excl_regex-0.1.0.tar.gz
| Download URL | py_incl_excl_regex-0.1.0.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b1c8f5ff25e475ed23e792461a82efe760e04fa2786e7c532b3d1e9a2ee6bf65
|
|
BLAKE2b-256 checksum How to use checksums |
086399500adb95043ba2b7fd3bd048776c43a816fe8e14645962a53948803bf7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.3
|
Release files / py_incl_excl_regex-0.1.0-py3-none-any.whl
| Download URL | py_incl_excl_regex-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
86037477cdee4244beeb72813e20f2045c457f5c0edc3f75b0db3d8bf00a9979
|
|
BLAKE2b-256 checksum How to use checksums |
9aa77c6986be6a403b57252bb9b5379fcd98bab89604a9b38e64a7991711b05b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.3
|
Security for py-incl-excl-regex 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.