Skip to main content

trim ()

Removes whitespace from both ends of a string. Whitespace in this context is all the whitespace characters (space, tab, no-break space, etc.) and all the line terminator characters (LF, CR, etc.).

Parameters

$string
The source string from which to remove leading and trailing whitespace.
Type
String

Return Value

String
A string stripped of whitespace from both its beginning and end. If neither the beginning or end of source string has any whitespace, the string is simply returned, with no exception being thrown.

Example

@use '@sass-fairy/string';

@debug string.trim(' Hey, you guys! ');
// "Hey, you guys!"