carlogtt_python_library.utils.string_tools module

This module contains useful functions to work with strings.

class carlogtt_python_library.utils.string_tools.StringUtils[source]

Bases: object

A collection of string utility functions including string normalization and random string generation.

get_random_string(length: int) str[source]

Generate a random string.

snake_case(string_to_normalize: str) str[source]

Normalize the given string by converting uppercase letters to lowercase and replacing whitespaces with underscores. The resulting string is stripped of leading and trailing underscores.

Parameters:

string_to_normalize – The original string that needs to be normalized.

Returns:

The normalized string with all uppercase characters converted to lowercase and all whitespaces replaced by underscores.

snake_case_v2(string_to_normalize: str) str[source]

Normalize the given string to snake_case by handling consecutive uppercase letters, digit boundaries, whitespaces, hyphens, and underscores.

Parameters:

string_to_normalize – The original string that needs to be normalized.

Returns:

The normalized snake_case string.