Build and explain Python Regex patterns in a human-friendly way
Project description
Description
- regexplainer consists of two main components:
Explainer (technically RegexTokenizer): It tokenizes a given input regex string pattern, and its explain() method then explains in simpler English what is going on. The output is customizable, i.e. whether you want to see the flags, where a particular token starts and its length, to see the full textual sub-token along with its break-down, etc. In your IDE, check the init parameters to the class. This is working pretty well and you can use it without many issues.
Builder (technically RegexBuilder): This is a class that you can instantiate, and start using its properties and methods to build a regex without having to remember the actual Regex syntax. Your Python IDE will prompt you once you type in a letter that is close to what you want to do. Unfortunately, this is very rough around the edges and needs quite a bit of work. Am working on it.
Note: This is an alpha version, and things may change quite a bit.
from regexplain import RegexTokenizer
regtokens = RegexTokenizer(r"[^\w\s-]")
regtokens.explain()
"""
Explaining Full Pattern: [^\w\s-]
┌──
│ [Span, Length] (0, 8), 8
│ [Flags] re.NOFLAG
│ ┌──
│──│ [^
│ │ [@0:Character Set] Matches any character not in the set
│ │ [Span, Length] (0, 8), 8
│ │ [Flags] re.NOFLAG
│ │ ┌──
│ │──│ \w
│ │ │ [@1:Character Class:Word] Matches any word character (alphanumeric and underscore)
│ │ │ [Span, Length] (2, 4), 2
│ │ │ [Flags] re.NOFLAG
│ │ └──
│ │ ┌──
│ │──│ \s
│ │ │ [@2:Character Class:Whitespace] Matches any whitespace character (space, tab, line-break)
│ │ │ [Span, Length] (4, 6), 2
│ │ │ [Flags] re.NOFLAG
│ │ └──
│ │ ┌──
│ │──│ -
│ │ │ [@3:Literal] Matches a single character from the list '-' (case-sensitive)
│ │ │ [Span, Length] (6, 7), 1
│ │ │ [Flags] re.NOFLAG
│ │ └──
│ │ ]
│ │ [@0:End] Token closed
│ └──
└──
"""
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 regexplain-0.1.0a16.tar.gz.
File metadata
- Download URL: regexplain-0.1.0a16.tar.gz
- Upload date:
- Size: 30.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.22.3 CPython/3.13.2 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8f1cd61a554faa1aab54fbecfcabc2b81aa18a2effe45117179f0e7fd1be8f3
|
|
| MD5 |
af48742194cebc21ad6d7aa8cb50b138
|
|
| BLAKE2b-256 |
f8bf02daf0d53d0df88d401b4c61ff4a01f4e8da48a8d9b297e0dfec9b79fd59
|
File details
Details for the file regexplain-0.1.0a16-py3-none-any.whl.
File metadata
- Download URL: regexplain-0.1.0a16-py3-none-any.whl
- Upload date:
- Size: 33.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.22.3 CPython/3.13.2 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9b6326b1f6215ad13ceec80b122574941f7a2cc8972eaa87e5914ba66d01647
|
|
| MD5 |
d875825d96899cc0d50441da542da196
|
|
| BLAKE2b-256 |
812ef34a56e8248ca3b451cd8d36bc12c956cb3e14db65de5be149404712ed10
|