Skip to main content

String generator by regex

Project description

String gen

PyPI Downloads PyPI - Python Version PyPI - Implementation

Code style: black

String generator by regex

Installation

Install using pip with

pip install string-gen

Example

from string_gen import StringGen

generator = StringGen(r'(A|B)\d{4}(\.|-)\d{1}')
print(generator.render())  # B9954.4
print(generator.render())  # A5292-1

generator = StringGen(r'[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}')
print(generator.render())  # 52aabe4b-01fa-4b33-8976-b53b09f49e72

# Generate list strings
generator = StringGen(r'(A|B)\d{4}(\.|-)\d{1}')
print(generator.render_list(5))  # ['A9046.5', 'A8334.7', 'B5496-6', 'A4207-2', 'A1171-7']

# Return a set of generated unique strings
generator = StringGen(r'\d')
print(generator.render_set(10))  # {'4', '6', '3', '9', '2', '7', '5', '1', '8', '0'}

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.12
  • pipenv 2023.11.15+
  1. Clone the repository
    git clone https://github.com/tolstislon/string-gen.git
    cd string-gen
    
  2. Install dev dependencies
    pipenv install --dev
    pipenv shell
    
  3. Run ruff format
    pipenv run format
    
  4. Run ruff check
    pipenv run check
    
  5. Run tests
    pipenv run tests
    

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

string_gen-0.1.1.tar.gz (11.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

string_gen-0.1.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file string_gen-0.1.1.tar.gz.

File metadata

  • Download URL: string_gen-0.1.1.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for string_gen-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9b60311ab0887c8f36f264135a0d863d1d71646e4b4d5aa9dfe7449123c5b4b2
MD5 c2f06f9455dd6ab004487448dde4f455
BLAKE2b-256 f9f042836da7736102ef9fab76134d81c53f38d35ba9f52e921cb135fcbcf451

See more details on using hashes here.

File details

Details for the file string_gen-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: string_gen-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for string_gen-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad83012165af83e7bddf5c9c0f77de68594b567c84f11126e0d509db13a8990c
MD5 5ae683b9062ff7a4c1892d6db0a6369c
BLAKE2b-256 1a9b6145b9558f1379395e32cd06161e909666d77bfa411d9283912048658ea2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page