A simple and light package for QA development which can generate random strings via RegExr.
Not all RegExr mechanics are available now. But you can use all base methods and generate any string.
New features
1.0.8:
- Finally, added () groups syntax support
- Global changes in generation start function (sorry, it's alpha)
Getting started
This package is tested with Python 3.9-3.11 and Pypy 3. There are two ways to install the library:
- Installation using pip (a Python package manager):
pip install re_generate
- Installation from source (requires git):
git clone https://github.com/Warrfie/re-generate
cd re-generate
python setup.py install
or:
pip install git+https://github.com/Warrfie/re-generate
It is generally recommended to use the first option.
Package is still under development, and it has regular updates, do not forget to update it regularly by calling
pip install re_generate --upgrade
What RegExr syntax supported
| type | is supported |
|---|---|
| [] square brackets | √ |
| [^] ! square brackets | √ |
| {} braces quantifiers | √ |
| {i,j} range braces quantifiers | √ |
| | or | √ |
| () groups | √ |
| \n,\s,\d...etc reserved samples | ✖ |
| *?,+?,?? greedy quantifiers | ✖ |
| *,+,? lazy quantifiers | ✖ |
Main functionality
How generate
from re_generate import re_generate
print(re_generate(r"69[0-9]abc[a-zA-Z]228"))
'693abcb228'
How generate several strings ot once
from re_generate import re_generate_list
print(re_generate_list(r"69[0-9]abc[a-zA-Z]228"), 10)
['694abcO228', '693abcG228', '692abcV228', '696abcy228', '693abca228', '690abcb228', '694abcD228', '696abck228', '696abcJ228', '692abca228']
What you can configue
If you want to use your own library
from re_generate import re_generator
re_generator.char_lib = "你f好п我Э的$中(国*朋Ъ友1234+=\/,."
Sometimes you need generate string without spaces at begin and end, like after .strip() function.
from re_generate import re_generator
re_generator.will_be_stripped = True
Tips and tricks
In large project you can link that lib throw cfg py file like that
cfg.py
from re_generate import re_generator
re_generator.char_lib = "你f好п我Э的$中(国*朋Ъ友1234+=\/,."
re_generator.will_be_stripped = True
your_func = re_generator.re_generator
and use it in your project
your_code.py
from cfg import your_func
print(your_func(r"69[^0-9]abc[a-zA-Z]22[ 8]"))
'69我abcb228'
Metadata
Release files for re-generate 0.1.8
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 |
|---|---|---|---|---|
| re-generate-0.1.8.tar.gz | 7.2 kB | Without provenance | Details for re-generate-0.1.8.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| re_generate-0.1.8-py3-none-any.whl | Python 3 | none | any | Details for re_generate-0.1.8-py3-none-any.whl |
Total release size: 14.0 kB
Release files / re-generate-0.1.8.tar.gz
| Download URL | re-generate-0.1.8.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ea702b3f965b811f6bf2aeb4300bfa4876239327136e51d333c172f2f724896
|
|
BLAKE2b-256 checksum How to use checksums |
a31b239537de8ec50943592d5084c370a74e8b0521b638444a823ab07f1c1dd5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Release files / re_generate-0.1.8-py3-none-any.whl
| Download URL | re_generate-0.1.8-py3-none-any.whl |
|---|---|
| Size | 6.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
36ae15f384b641d2912848bf6753d15d6c645e8e6aa905b00b0a6173c971d9e0
|
|
BLAKE2b-256 checksum How to use checksums |
49de78e18c3fb8e92e2520904827b72e297beed331228ddf2d606d5a765137d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.8
|
Security for re-generate 0.1.8
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.