python_technical_primitives.text.operations

String utility operations.

Functions

to_sentence_case(→ str)

Convert string to sentence case (first letter capitalized).

to_lower_case(→ str)

Convert string to lowercase.

to_upper_case(→ str)

Convert string to uppercase.

truncate(→ str)

Truncate string to max length with suffix.

normalize_whitespace(→ str)

Normalize whitespace (collapse multiple spaces to single).

is_valid_email(→ bool)

Check if string is valid email format.

sanitize_filename(→ str)

Sanitize filename by removing/replacing invalid characters.

extract_extension(→ Optional[str])

Extract file extension from filename.

Module Contents

python_technical_primitives.text.operations.to_sentence_case(text: str) str

Convert string to sentence case (first letter capitalized).

python_technical_primitives.text.operations.to_lower_case(text: str) str

Convert string to lowercase.

python_technical_primitives.text.operations.to_upper_case(text: str) str

Convert string to uppercase.

python_technical_primitives.text.operations.truncate(text: str, max_length: int, suffix: str = '...') str

Truncate string to max length with suffix.

Args:

text: String to truncate max_length: Maximum length including suffix suffix: Suffix to add if truncated

Returns:

Truncated string

python_technical_primitives.text.operations.normalize_whitespace(text: str) str

Normalize whitespace (collapse multiple spaces to single).

python_technical_primitives.text.operations.is_valid_email(email: str) bool

Check if string is valid email format.

python_technical_primitives.text.operations.sanitize_filename(filename: str) str

Sanitize filename by removing/replacing invalid characters.

Args:

filename: Original filename

Returns:

Sanitized filename safe for file systems

python_technical_primitives.text.operations.extract_extension(filename: str) str | None

Extract file extension from filename.