SplitScript reference / String / trimAsciiWhitespace

String.trimAsciiWhitespace

Method

String.trimAsciiWhitespace() -> String

Removes ASCII whitespace from both ends of this string.

ASCII space, tab, line feed, vertical tab, form feed, and carriage return are removed. Interior bytes and every non-ASCII character are preserved. If neither end changes, the existing immutable string is reused without allocating.

Effects: allocates

Runtime behavior: available everywhere; synchronous

Examples

Clean a line read from a game log

let eventName = "  boss defeated  ".trimAsciiWhitespace()