JavaScript 实现 PHP (trim)

// Trim() , Ltrim() , RTrim()

String.prototype.Trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, “”);
}

String.prototype.LTrim = function()
{
return this.replace(/(^\s*)/g, “”);
}

String.prototype.RTrim = function()
{
return this.replace(/(\s*$)/g, “”);
}

 

Tags: ,

Comments

No comments so far.
  • Leave a Reply
     
    Your gravatar
    Your Name
     
     
     
     
     
 
About This Website

Lamp development & SEO & Plan of Website & Project Managment

Learn more »
Follow Us (SNS)
Help & Support

more about Bruce.xu»

Get in touch

QQ: +252339382
Email: shjuto @ gmail.com

Online contact form »