Regular Expressions for Sequences of Things
Project description
Welcome to RegEx4Seq
This is a python library that implements regular-expression based pattern matches for sequences of arbitrary objects. For example you can write pattern to determine if a list is a sequence of alternating 1's and 0's like this:
from regex4seq import Item, Items
# The core is a repetition of alternating 0s and 1s. But we need to
# account for the pattern starting on a 1 or finishing on a zero.
# Analogous to the regex /1?[01]*0?/.
pattern = Item(1).optional() & Items(0, 1).repeat() & Item(0).optional()
pattern.matches( [1, 0, 1, 0, 1, 0, 1])
# True
pattern.matches( [1, 0, 1, 0, 1, 0, 0])
# False
To learn more about the library, go to the documentation page on ReadTheDocs.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
regex4seq-0.3.0.tar.gz
(7.4 kB
view details)
Built Distribution
File details
Details for the file regex4seq-0.3.0.tar.gz
.
File metadata
- Download URL: regex4seq-0.3.0.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/6.2.0-10018-tuxedo
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b47881b9e87622e03208aea7e6a7bfcb04403c82359ee7653c8adf1895115cc |
|
MD5 | e222e8f28cf200cf24ce15eb44a62a51 |
|
BLAKE2b-256 | 6c9a50982e0c6652b7761bad7054cfc9744c1e91c67ae336e289fad69e74250d |
File details
Details for the file regex4seq-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: regex4seq-0.3.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.12 Linux/6.2.0-10018-tuxedo
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c0b19af96f87ede6992d7a7a1601c30382841130e43f28dada825966d0e07f9 |
|
MD5 | 0dfb663a2a866db89a0dad4d59a6fca6 |
|
BLAKE2b-256 | 078e67ea008ffb26e744f361eacfcfbc3ef4c74d21ce86663c6c490f5349ee88 |