Skip to main content

normalize_whitespace

Normalizes whitespace in a string by replacing all occurrences of ASCII whitespace characters with a single space.

def normalize_whitespace(
string: string
) - > string

Replaces all occurrences of ASCII whitespace characters with a single space to ensure consistent string formatting.

Parameters

NameTypeDescription
stringstringThe input text containing potential tabs, newlines, or multiple spaces to be normalized.

Returns

TypeDescription
stringThe processed string with all whitespace sequences collapsed into single spaces.