For editing strings in many ways.
Project description
📝 stringtools
This module provides string operations, such as analaysing, converting, generating, validating.
It has tons of functions, and classes especially built to be fast and stable ⚡.
There are 4 categories:
analaysers - Analyse string.
ispangram | is_heterogram | is_anagram | is_palindrome | is_tautogram | count_chars | count_words |
converters - Convert one string value to other string value.
bricks | replaceall | numerate_text | remove_trailing_whitespaces | remove_leading_whitespaces |
generators - Generate text inforamation.
generate_nick | GeneratePassword |
validators - Validate ip, email addresses, e.t.c
validate_semver | validate_email | validate_ipv4 | validate_ipv6 | validate_url |
Installation:
pip install stringtools
Usage/Examples
analaysers:
ispangram()
↑ Checks if inputed string is pangram (A pangram is a sentence using every letter of a given alphabet at least once.)
is_pangram('Watch "Jeopardy!", Alex Trebek\'s fun TV quiz game.')
# -> True
is_pangram('Hello beautiful world!')
# -> False
is_heterogram()
↑ Checks if inputed string is heterogram (A heterogram is a string in which no letter of the alphabet occurs more than once.)
is_heterogram("abcd")
# -> True
is_heterogram("abcdd")
# -> False
is_anagram()
↑ Checks if inputed string is an anagram (Anagram is a string that contain all letters from other string.)
is_anagram("Tom Marvolo Riddle", "I Am Lord Voldemort")
# -> True
is_anagram("God", "Good")
# -> False
is_palindrome()
↑ Checks if inputed string is a palindrome (A palindrome is a word, number, phrase, or other sequence of characters which reads the same backward as forward, such as madam or racecar.)
is_palindrome(["r","a","d","a","r"])
# -> True
is_palindrome(123)
# -> False
is_tautogram()
↑ Checks if inputed string is a tautogram (A tautogram is a text in which all words start with the same letter.)
is_tautogram("Crazy cat, cute, cuddly")
# -> True
is_tautogram("Crazy mouse, cute, cuddly")
# -> False
count_chars()
↑ Returns dictionary with every character counted.
count_chars("OOPp")
# -> {"O": 2, "P": 1, "p": 1}
count_chars("OOPp", lowercase=True)
# -> {"o": 2, "p": 2}
count_words()
↑ Returns an integer with every word counted.
count_words("Hello world!")
# -> 2
count_words("This is me")
# -> 3
converters:
bricks()
↑ Returns bricked version of a string.
bricks("Hello world!")
# -> "HeLlO WoRlD!
bricks("abcdef")
# -> "AbCdEf"
replaceall()
↑ Replaces text from given sentence and dictionary.
dictionary should be formatted like this:
{"old_string": "new_string"}
replaceall("12345", {"1": "One ", "2": "Two ", "3": "Three "})
# -> "One Two Three 45"
replaceall("Hello world!", {"Hello": "Sup", "world": "earth"})
# -> "Sup earth!"
numerate_text()
↑ Numerate each line of text.
numerate_text("Hello world\nHow are you doing?")
# -> "1 Hello World\\n2 How are you doing?"
numerate_text("First line.\nThe second line\nThe third line")
# -> "1 First line.\n2 The second line\n3 The third line"
remove_trailing_whitespaces()
↑ Remove all trailing whitespaces from sentence.
dictionary should be formatted like this
remove_trailing_whitespaces("text ")
# -> "text"
remove_trailing_whitespaces("Look at this. ")
# -> "Look at this."'''
remove_leading_whitespaces()
↑ Remove all leading whitespaces from sentence.
dictionary should be formatted like this
remove_leading_whitespaces(" text")
# -> "text"
remove_leading_whitespaces(" Look at this.")
# -> "Look at this."'''
generators:
generate_nick()
↑ Generate nicknames by inputed vowels, consonants, and other sounds.
for i in range(20):
print(stringtools.generate_nick(length=5))
# ->
# Irrol
# Uppuq
# Aguir
# Moury
# Uwrax
# Ezeoa
# Agaum
# Egeti
# Efuyu
# Iruek
# Qawze
# Oguei
# Hochu
# Maqod
# Suyff
# Idoor
# Keigh
# Uredi
# Eceuy
# Elere
GeneratePassword()
↑ Generate very strong passwords.
You can choose these options for password:
- English (abcd...)
- Numerals (1234...)
- Special Symbols ('`<*...)
- Own symbols (Any)
- Exclude similar characters (1, l, L, 0, o, O, etc.)
GeneratePassword(length=50, english=True, symbols=True, numerals=True, exclude_similarities=True)
# -> "C-3?r#$a#[7n>!5\7<8s,(4W)2324C44(-3[4,!%$-!1k1+(Mg"
GeneratePassword(length=50, english=False, symbols=True, numerals=True)
# -> "_;53.?30,>92:;=.+$}>[>'6;8$1~_'>8$=504-`751]>434_&"
validators:
Validator.validate_semver()
↑ Validate if version name follows semantic versioning. For more information go to: https://semver.org/
Validator.validate_semver("1.0.0")
# -> True
Validator.validate_semver("1.0.0.0")
# -> False
Validator.validate_email()
↑ Validate an email address.
Validator.validate_email("email@example.com")
# -> True
Validator.validate_email("email@example..com")
# -> False
Validator.validate_url()
↑ Validate url address.
Validator.validate_url("https://example.com/")
# -> True
Validator.validate_url("example.com")
# -> False
Validator.validate_ipv4()
↑ Validate an ipv4 address.
Validator.validate_ipv4("127.255.255.254")
# -> True
Validator.validate_ipv4("127.255.254")
# -> False
Validator.validate_ipv6()
↑ Validate an ipv6 address.
Validator.validate_ipv6("2345:0425:2CA1:0000:0000:0567:5673:23b5")
# -> True
Validator.validate_ipv6("0425:2CA1:0000:0000:0567:5673:23b5")
# -> False
Authors
License 🔑
MIT - Copyright (c) 2022 Beksultan Artykbaev
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
stringtools-1.1.0.tar.gz
(11.3 kB
view hashes)
Built Distribution
Close
Hashes for stringtools-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81239bffd5e73a23a065bfe803e6d3b8d21822db38d613b20d9f3ed5dae3ee67 |
|
MD5 | 33492be4b70299679da7551becd8474c |
|
BLAKE2b-256 | c90f29c902330afc114223b03e0f32a61edd4e19bdaa4358144a73b71a010b4c |