PP.trim

Syntax

trim(string: String);

Parameters

string. Text to format.

Description

The trim method removes white space characters from the beginning and end of a string.

Comments

This method returns a String value.

Example

To execute the example, add a link to PP.js scenario file to HTML page. Determine a string that contains white space characters, and remove the first and the last occurrence:

// Determine string with spaces
var str = " pro gnoz ";
console.log("Source string: «" + str + "»");
// Remove spaces from the beginning and the end of the string
str = PP.trim(str);
console.log("String with removed start and end spaces: «" + str + "»");

fAfter executing the example the browser console displays source string and the string with white space characters trimmed from the beginning and end of it:

Source string: « pro gnoz »
String with trimmed white space characters at the beginning and end: «pro gnoz»

See also:

PP