Skip to main content

Python package for playing with strings

Project description

string-decorator

Python Module to have fun with strings
PyPI version Downloads Downloads License: MIT

Usage

Example 1 -> Calculating expression from given string

from string_decorator import calculate
print(calculate("(123+23) * 23 / 32"))

Output

104.9375

Example 2 -> Validating text based on given conditions

from string_decorator import validate_text
print(validate_text("imEternity1234@strings", length = 13, uppercase = 1, lowercase = 5, numbers = 4, special_characters=1))

Output

True

Example 3 -> Converting the string to random cases

from string_decorator import randcase
print(randcase("hello"))

Output

hELlO

Example 4 -> Extracting numbers from the given string

from string_decorator import num_extract
print(num_extract("hello123 23,211 42.23 -134 g00d"))

Output

['123', '23,211', '42.23', '-134', '00']

Example 5 -> Changing string to CONSTANT_CASE

from string_decorator import constantcase
print(constantcase("hello there"))

Output

HELLO_THERE

Documentation

text is a common parameter for all the functions

Name Description
randcase Changes the given text to random cases (upper or lower)
snakecase Changes the given text to snake_case
constantcase Changes the given text to CONSTANT_CASE
kebabcase Changes the given text to kebab-case
headercase Changes the given text to PascalCase
camelcase Changes the given text to camelCase
dotcase Changes the given text to dot.case
pathcase Changes the given text to path/case
swapcase Changes each upper characters to lower and vice versa
scramble_sentence Returns the sentence in random order Eg: 'Hello my friend' might change to 'my friend Hello'
sentence_reverse Reverses given sentence Eg: 'Hello world' changes to 'world Hello'
random_string Generates a random string comprising of lower cased or upper cased characters, numbers, symbols
str_encode Encodes the given text into bytes format
bytes_decode Decodes bytes back to string
num_extract Extracts numbers from the given strings
parameters:
- string: Set it to True to return numbers in a list of strings
validate_email Validates the text to check if the email format is correct
validate_text Validates the text to check if it is right according to the conditions specified
parameters:
- length: The minimum length of the text
- uppercase: The minimum number of uppercase letters in the text. Set to 'all' if all letters have to be in uppercase.
- lowercase: The minimum number of lowercase letters in the text. Set to 'all' if all letters have to be in lowercase.
- numbers: The minimum number of numbers (positive integers) in the text. Set to 'all' if all are numbers.
- special_characters: The minimum number of special characters in the text. Set to 'all' if all are special characters.
calculate Evaluates the given string
Eg: "5+2" gives 7

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_decorator-0.4.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

string_decorator-0.4.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file string_decorator-0.4.0.tar.gz.

File metadata

  • Download URL: string_decorator-0.4.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for string_decorator-0.4.0.tar.gz
Algorithm Hash digest
SHA256 25d807767c5f56fdea75f3da25b1dafa21f876cf26a2c3db6e45649df5255be8
MD5 292446892bc9c7abc9c03d7c8934579e
BLAKE2b-256 4601aa9ba91efad255d05f2b6ef7a791e32ee807e8bd517ae9acd55d0f4f5964

See more details on using hashes here.

File details

Details for the file string_decorator-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for string_decorator-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0f6d011fbf53d9acc63db2b3d8e7968f6315f91efbee5a74da518be20be2827d
MD5 5b25d1afce5e7cce097eeb200d0f5219
BLAKE2b-256 21bed0300b7f9c969851986b86ab7a51a30bef0e491c920bd2d68674bab61f2b

See more details on using hashes here.

Supported by

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