trim(string: String);
string. Text to format.
The trim method removes white space characters from the beginning and end of a string.
This method returns a String value.
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: