Developer Blog

Trim function applied to Javascript

The following code will help to apply “Trim” function in javascript. Here is an example where we are retriving data from a prompt message box then applying “Ltrim” & “RTrim” like functions. 

var sData = prompt(”Enter The Name”,”");           // Receives data from user
 var sLeft = /\s*((\S+\s*)*)/;
 var sRight = /((\s*\S+)*)\s*/;
 sData = sData.replace(sLeft, “$1″);              // Removes blank spaces from left
 sData = sData.replace(sRight, “$1″);           //  Removes blank spaces from right

Leave a Reply

*
To prove you're a person (not a spam script), type the security word shown in the picture.
Anti-Spam Image



Get Download Files Review Project Dashboard Know Plan And Wishlist