trim_whitespace
Trims leading and trailing whitespace from a string and replaces internal whitespace sequences with a single space using regular expressions.
def trim_whitespace(
s: string
) - > string
Removes leading and trailing whitespace from a string and collapses all internal whitespace sequences into a single space.
Parameters
| Name | Type | Description |
|---|---|---|
| s | string | The input string containing potential leading, trailing, or redundant internal whitespace to be normalized. |
Returns
| Type | Description |
|---|---|
string | The cleaned string with normalized spacing, suitable for consistent display or storage. |