Code
function String.prototype.Trim() { return this.replace(/(^/s*)|(/s*$)/g, ""); } // Remove left and right spaces
function String.prototype.Ltrim() { return this.replace( /(^/s*)/g, ""); } // Remove the left space
function String.prototype.Rtrim() { return this.replace(/(/s*$)/g, "") ;} // Remove the right space
Example
Let’s take a look at what “/s means” in Js scripts.
s matches any whitespace character, including Spaces, tabs, form feeds, etc. Equivalent to [fnrtv].
Please remember that it is lowercase s