Regular expressions for the 21st century. Match any data type.
Project description
Non-String Regular Expressions
NSRE (Non-String Regular Expressions) is a new spin at regular expressions. It's really abstract, even compared to regular expressions as you know them, but it's also pretty powerful for some uses.
Here's the twist: what if regular expressions could, instead of matching just character strings, match any sequence of anything?
from nsre import *
re = RegExp.from_ast(seq('hello, ') + (seq('foo') | seq('bar')))
assert re.match('hello, foo')
The main goal here is matching NLU grammars when there is several possible interpretations of a single word, however there is a lot of other things that you could do. You just need to understand what NSRE is and apply it to something.
Note — This is inspired by this article from Russ Cox, which explains how Thompson NFA work, except that I needed to add some features and then the implementation is much less elegant because I actually don't know what I'm doing. But it seems to be working.
Documentation
Licence
This library is provided under the terms of the WTFPL.
If you find it useful, you can have a look at the contributors page to know who helped.
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
File details
Details for the file nsre-0.2.0.tar.gz
.
File metadata
- Download URL: nsre-0.2.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.3 CPython/3.6.8 Linux/4.15.0-76-lowlatency
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a1e749c75f190fbc8f32a67394a554117a97f625a32cde5704e187cb2edefab |
|
MD5 | a9da154fd16a4a987931e642f718b261 |
|
BLAKE2b-256 | 8c826b0bb758b8a463b88e02e98fa43ed57f647e3e88d66fcc0d6dcbe6b39558 |
File details
Details for the file nsre-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: nsre-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.3 CPython/3.6.8 Linux/4.15.0-76-lowlatency
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0082e91537c9f095a0eea11160b64d3cb7828332d50d0b926362d63d241dd04d |
|
MD5 | e8cec7b8c6de52baf3044b5516836ed7 |
|
BLAKE2b-256 | 3dcabccac5168f94ab4bc58c99158b339d715070e50c9d82e881915b2b3025f4 |