PP.String.trim(string: String);
string. Text to be formatted.
The trim static method trims white spaces at the beginning and at the end of the string.
This method returns a String-type value.
NOTE. This method replaces the outdated PP.trim method.
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: