trim() function Java Script


Use these function in Java Script body :
----------------------------------------------------------------------------------------------------
function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function TestTrimString(){
     var testString="  Hello!  "
    document.write("String before  triming:" + testString );  
    document.write("String after     triming:" + trim(testString) );
}

------------------------------------------------------------------------------------------------------

Comments

Popular posts from this blog

Struts 2 : Warning :No configuration found for the specified action: 'Login.action' in namespace: '/'

Upload csv file at Google Cloud Storage using java

Read Images from a xlsx file using Apache POI