Generates random strings that match a given regex pattern
Project description
Regex String Generator
Overview
Regex String Generator is a Python package that allows you to generate random strings that match a given regular expression pattern.
Features
Installation
Install the package using pip:
pip install regex-string-generator
Use Cases
Create random strings for various purposes such as database seeding, API testing, form validation, or any other scenario where you need controlled random data that adheres to specific formats.
- Testing: Generate test data that matches the input validation rules of your application. This ensures your application handles all expected input formats correctly.
- Validate Regex: Check the effectiveness of your regex patterns by generating matching strings. This helps you understand if your regex is too broad or too restrictive.
- Regex Learning Tool: For those learning regular expressions, this package provides a way to see examples of strings that match specific patterns, helping to reinforce understanding.
Usage Examples
Here's how you can use the generate_string
function.
Example 1: Generate a simple username
from regex_string_generator import generate_string
username_pattern = r"[a-z]{8}" # 8 lowercase letters
username = generate_string(username_pattern)
print(f"Generated username: {username}")
# Output: Generated username: abcdefgh
Example 2: Generate a simple password
from regex_string_generator import generate_string
password_pattern = r"[A-Za-z0-9]{10}" # 10 alphanumeric characters
password = generate_string(password_pattern)
print(f"Generated password: {password}")
# Output: Generated password: Ab3d5Fg2h9
Example 3: Generate a simple hexadecimal color code
from regex_string_generator import generate_string
color_pattern = r"#[A-Fa-f0-9]{6}" # Hex color code
color = generate_string(color_pattern)
print(f"Generated color code: {color}")
# Output: Generated color code: #1A2B3C
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 regex_string_generator-0.0.1.tar.gz
.
File metadata
- Download URL: regex_string_generator-0.0.1.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f98eb15ceaf473349ba8e3267bdceaafafb9885bccc0cb654141a1ac1f1ddadc |
|
MD5 | 4719e0f4baa68a6ca66e98afade975c5 |
|
BLAKE2b-256 | c6ef79447b1327e6e2d846f12aa3a3ccc98ebb841320b9f8c2e9d49320e54851 |
File details
Details for the file regex_string_generator-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: regex_string_generator-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e484969f7820bc3e339c1910a5be9937de791f31a5ca09377ae14e739e36c1d |
|
MD5 | 58910c0567600136343cf6e1aa65195f |
|
BLAKE2b-256 | 9f3c85005c64705d9a2fe5d47b5a53ef1f5de91d1c5c86f398a600bea7d92310 |