String gen
Generate random strings from regular expression patterns.
string-gen takes a regex pattern and produces random strings that match it. Common use cases include:
- Test data generation — create realistic inputs for unit and integration tests
- Fixtures — produce parameterized test fixtures on the fly
- Fuzzing — generate semi-structured random inputs for fuzz testing
- Mock data — build placeholder data for prototyping and demos
Documentation | API Reference | Cookbook
Installation
pip install string-gen
Quick Start
from string_gen import StringGen
# Basic generation
gen = StringGen(r'(A|B)\d{4}(\.|-)\d{1}')
gen.render() # e.g. 'B9954.4'
# List of strings
gen = StringGen(r'[A-Z]{3}-\d{3}')
gen.render_list(5) # e.g. ['XKR-839', 'BNQ-271', 'JYL-054', 'WMT-692', 'AFZ-418']
# Built-in patterns
from string_gen.patterns import UUID4, IPV4
StringGen(UUID4).render() # e.g. '52aabe4b-01fa-4b33-8976-b53b09f49e72'
StringGen(IPV4).render() # e.g. '192.168.1.42'
# Custom alphabets
from string_gen.alphabets import CYRILLIC
StringGen(r'\w{10}', alphabet=CYRILLIC).render() # e.g. 'ёЩкРблнЫйМ'
For full documentation visit tolstislon.github.io/string-gen.
Changelog
Contributing
Contributions are very welcome. You might want to:
- Fix spelling errors
- Improve documentation
- Add tests for untested code
- Add new features
- Fix bugs
Getting started
- Python 3.8+
- uv
- Clone the repository
git clone https://github.com/tolstislon/string-gen.git cd string-gen
- Install dev dependencies
uv sync - Run ruff format
uv run ruff format
- Run ruff check
uv run ruff check --fix
- Run tests
uv run pytest tests/
Metadata
Release files for string-gen 1.0.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 |
|---|---|---|---|---|
| string_gen-1.0.0.tar.gz | 39.4 kB | Without provenance | Details for string_gen-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| string_gen-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for string_gen-1.0.0-py3-none-any.whl |
Total release size: 62.1 kB
Release files / string_gen-1.0.0.tar.gz
| Download URL | string_gen-1.0.0.tar.gz |
|---|---|
| Size | 39.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b9e756760ca396888cf16afa4873a8a2242cfe89c869e1645538c45aa0f301bd
|
|
BLAKE2b-256 checksum How to use checksums |
5ed46118e1331b44164fca7bb43ce540a7261f45731622571aa94c8050a2e704
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / string_gen-1.0.0-py3-none-any.whl
| Download URL | string_gen-1.0.0-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2510e5b5b857e499c5af9ee4f2c20e51b8b14e3a15e2c52fc8aa6a00ccf5bc44
|
|
BLAKE2b-256 checksum How to use checksums |
7bb144f7cb6c5c101d19bf203590a38a3eff3af233d746536cca5ac6695fd337
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for string-gen 1.0.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.