String.trim

Syntax

PP.String.trim(string: String);

Parameters

string. Text to be formatted.

Description

The trim static method trims white spaces at the beginning and at the end of the string.

Comments

This method returns a String-type value.

NOTE. This method replaces the outdated PP.trim method.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Determine a string that contains white spaces, and trim only the ones at the beginning and at the end:

// Set a source string
var sourceStr = "  abc ";
console.log("Source string: «" + sourceStr + "»");
// Get a string without start and end white spaces
var result = PP.String.trim(sourceStr);
console.log("String without start and end white spaces: «" + result + "»");

After executing the example the browser console displays the source string and string without white spaces at the beginning and at the end:

Source string: "  abc "

String without start and end white spaces: "abc"

See also:

PP