There is no function to trim string in javascript. We can use following user define function to trim string using javascript. Mainly we need three type of trim function which we use in program.
Right Trim Javascript User Define function.
function rightTrim(str)
{
return str.replace(/\str+$/,"");
}
Left Trim Javascript User Define function.
function leftTrim(str)
{
return str.replace(/^\str+/,"");
}
Trim javascript function for both left and right side.
function trim(str)
{
return str.replace(/^\str+|\str+$/g,"");
}
Comments
Post a Comment