Posted By

donkeykong on 07/14/08


Tagged

javascript methods strings


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

wizard04
pollux


javascript string methods


 / Published in: JavaScript
 

sample: var text = " string content ";

text = text.trim();

  1. String.prototype.trim = function() {
  2. return this.replace(/^\s+|\s+$/g,"");
  3. }
  4. String.prototype.ltrim = function() {
  5. return this.replace(/^\s+/,"");
  6. }
  7. String.prototype.rtrim = function() {
  8. return this.replace(/\s+$/,"");
  9. }

Report this snippet  

You need to login to post a comment.