X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=string_utils.py;h=a2f46332156e0c5fc41f3db8a8228a149272651c;hb=e11d9b0958b2874bd67360552e9214d965fe0d12;hp=37851e04e7e5cba26ea0ac6032635e3ca5bfa2ed;hpb=89f305d67e913ea1512e2618a0375359ec925ada;p=python_utils.git diff --git a/string_utils.py b/string_utils.py index 37851e0..a2f4633 100644 --- a/string_utils.py +++ b/string_utils.py @@ -857,6 +857,10 @@ def words_count(in_str: str) -> int: return len(WORDS_COUNT_RE.findall(in_str)) +def word_count(in_str: str) -> int: + return words_count(in_str) + + def generate_uuid(omit_dashes: bool = False) -> str: """ Generated an UUID string (using `uuid.uuid4()`). @@ -876,7 +880,9 @@ def generate_random_alphanumeric_string(size: int) -> str: Returns a string of the specified size containing random characters (uppercase/lowercase ascii letters and digits). - random_string(9) # possible output: "cx3QQbzYg" + >>> random.seed(22) + >>> generate_random_alphanumeric_string(9) + '96ipbNClS' """ if size < 1: @@ -971,6 +977,10 @@ def shuffle(in_str: str) -> str: return from_char_list(chars) +def scramble(in_str: str) -> str: + return shuffle(in_str) + + def strip_html(in_str: str, keep_tag_content: bool = False) -> str: """ Remove html code contained into the given string.