To Trim or not to Trim !!!!!!

Results 1 to 3 of 3

Thread: To Trim or not to Trim !!!!!!

  1. #1
    Sid Guest

    Default To Trim or not to Trim !!!!!!

    Is there a jscript version of Trim ?<BR><BR>Can&#039t find a ref anywhere.<BR><BR>TIA<BR><BR>Sid

  2. #2
    Dan Evans Guest

    Default RE: To Trim or not to Trim !!!!!!

    Even if there isn&#039t a command for it, it&#039s not hard to make your own. This one uses regular expression commands:<BR><BR>&#060;script language = javascript&#062;<BR>alert("==" + trim(" Hello ") + "==");<BR><BR>function trim(str) {<BR> if (str.match(/^s+/) &#124&#124 str.match(/s+$/)) {<BR> str = str.replace(/^s+/, "");<BR> str = str.replace(/s+$/, "");<BR> }<BR> return str;<BR>}<BR>&#060;/script&#062;<BR><BR>-Dan Evans

  3. #3
    Sid Guest

    Default Thanks

    Thanks for that after a bit of tweeking it works just fine !!!<BR>Heres what i did<BR>str = myform.myfield.value<BR>str = str.replace(/s/g, "");<BR>Thanks again<BR><BR>Sid

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts