Trim is a good features when you try to delete the space at the left most, right most or both the left most and right most of the string. The following trim function is ultilize the javascript Regular expression for the trim function
Left Trim
function ltrim(str){
return str.replace(/^s+/, ”);
}
Right Trim
function rtrim(str) {
return str.replace(/s+$/, ”);
}
All trim
function alltrim(str) {
return str.replace(/^s+|s+$/g, ”);
}
Popularity: 1% [?]
Related posts:
- Form validation not allow chinese cheractor the following example use the javascript regular express to validate...
- HTML table word wrap I created a table to display a link which consist...
- Attaching event in both MSIE and FF with Javascript Most of the developer who working in MS platform will...
- URL Hidden Tricks to check page’s last update Check the page’s last update date Go to any web...



Comments
No Responses to “Trim a string in Javascript”