pysnippets.strings
Slugs, naming cases, words and character checks.
- byte_size(text, encoding)Count the bytes a string takes up once encoded, which len() doesn't tell you.
- hamming_distance(a, b)Count the positions at which two equal-length strings differ.
- hex_to_rgb(color) +1Parse #RRGGBB and #RGB colours into (r, g, b), and format them back.
- is_anagram(a, b)Compare letter counts, ignoring case, spaces and punctuation.
- is_palindrome(text)Check whether text reads the same reversed, ignoring case, spaces and punctuation.
- split_words(text) +4Convert text between snake_case, kebab-case, camelCase and PascalCase, acronyms included.
- slugify(text)Make a lowercase, ASCII, hyphen-separated slug from any text, including accented letters.
- words(text, pattern)Extract the words from text with a regex, keeping apostrophes and hyphens inside words.