Skip to main content

strip(stringToStrip)

Removes any whitespace from the both ends of a string

Availability

Device + Agent

Parameters

Name Type Description
stringToStrip String Any string

Returns

String — the truncated string

Description

This function removes any and all space characters from both the beginning and the end of the passed string. It returns the result as a new string, leaving the original string intact.

Because strip() is implemented as a function, it does not use dot syntax.

Example Code

local aString = " This string starts and ends with rogue spaces ";
local newString = strip(aString);
server.log(newString);
// Displays "This string starts and ends with rogue spaces"