Skip to main content

Extended string utilities with CLI

Project description

stringx

stringx is an extended string utility library for Python.
It re-exports everything from the built-in string module and adds a wide range of practical helpers for:

  • Case conversion (snake_case, camelCase, PascalCase, kebab-case, Title Case)
  • Slugification and safe filenames
  • Character filters (only_digits, only_letters, only_alnum, etc.)
  • Random string and secure token generation
  • Validators (is_uuid, is_hex)
  • Text cleanup (normalize_space, strip_accents)
  • CLI for quick usage from the terminal

Installation

pip install stringx

Quick Examples

from stringx import random_string, slugify, to_snake, to_camel, is_uuid, safe_filename

# Generate secure random strings
print(random_string(16, "letters+digits", secure=True))

# Slugify text
print(slugify("Hello, World!"))  
# "hello-world"

# Convert cases
print(to_snake("HTTPResponseCode"))    # "http_response_code"
print(to_camel("http_response_code"))  # "httpResponseCode"

# Validate UUID
print(is_uuid("123e4567-e89b-12d3-a456-426614174000"))  
# True

# Make filenames safe
print(safe_filename("Quarterly Report: Q1/2025.pdf", allow_dot=True))  
# "Quarterly_Report_Q1_2025.pdf"

CLI Usage

stringx also comes with a command-line tool:

# Generate a secure random string
stringx gen --length 20 --charset letters+digits --secure

# Slugify text
stringx slugify "Hello, World!"  
# hello-world

# Convert to snake_case
stringx case "MyExampleString" --to snake

# Keep only digits
stringx filter "a1b2c3" --only digits

# Validate UUID
stringx validate "123e4567-e89b-12d3-a456-426614174000" --uuid

# Normalize spaces
stringx normalize-space "foo    bar   baz"  
# "foo bar baz"

Advanced Examples

Slugify with Unicode

from stringx import slugify
print(slugify("Café déjà vu", allow_unicode=True))
# "café-déjà-vu"

Character n-grams

from stringx import ngrams
print(ngrams("banana", 2))
# ['ba', 'an', 'na', 'an', 'na']

Character frequency

from stringx import char_freq
print(char_freq("banana"))
# {'b': 1, 'a': 3, 'n': 2}

API Reference

  • random_string(length=12, charset="letters+digits", secure=False)
  • secure_token(nbytes=16, urlsafe=True)
  • slugify(text, allow_unicode=False, sep="-")
  • to_snake, to_kebab, to_camel, to_pascal, to_title
  • strip_accents, normalize_space
  • only_letters, only_digits, only_alnum, only_printable
  • is_uuid, is_hex
  • ngrams, chunks, char_freq
  • safe_filename, ensure_prefix, ensure_suffix
  • repeat, truncate, pad_left, pad_right
  • fill_template

License

MIT © Ahamed

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

stringplus-0.1.1.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

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

stringplus-0.1.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for stringplus-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8df92f272b2dbb1c8f35002479fe271067498bc50fb89d434efdfeff746cf666
MD5 812c65ddaf9fb31d4c212031abfaba77
BLAKE2b-256 c9ea8b0377495b2ad19b3c4677d452cc57d72879ebfb666b9e1b57a682807c0a

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for stringplus-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f85f0b241e45fb897d854cd240d9ee98267fa653cbfc2c85e3f010ca4e6dc066
MD5 82e92f4b8c757df4adcb85621ee59f27
BLAKE2b-256 3ff4aa9d0e66a53f4198718f2ed6fc0611db1a76a612687b516dec6cc4798385

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