String.prototype.trim = function ()
{
// Use a regular expression will be on the front and rear spaces
// replace it with an empty string.
Return this.Replace (/ (^ / s *) | (/ s * $) / g, "");
}
// String with spaces
Var s = "Leading and trailing spaces";
// Show "Leading and Trailing Spaces (35)"
WINDOW.Alert (" S.Length ") ")
// Delete the front and rear spaces
s = S.trim ();
// Show "Leading and Trailing Spaces (27)"
WINDOW.Alert (" S.Length ") ")