Results 1 to 2 of 2

Thread: JavaScript RTrim Fuction

  1. #1

    Thread Starter
    Addicted Member TheGoldenShogun's Avatar
    Join Date
    Mar 2001
    Location
    VA/MD... anywhere around the beltway
    Posts
    236

    JavaScript RTrim Fuction

    Is there a JavaScript function that allows to to strip all the blank spaces to the right of the last character. I know VBScript has a RTrim function, does JavaScript have an equivilent?

  2. #2
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    You can use a RegEx.
    Code:
    myString.Replace(/\s+$/, "");
    Now, I don't remember in JavaScript if it will match the largest it can or the first it finds. You might have to make the expression greedy to get what you want.
    Code:
    myString.Replace(/\s+$/g, "");
    Try it and see what works.
    Travis, Kung Foo Journeyman
    As always, RTFM.

    WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
    Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
    YBMS, but Mozilla doesn't.

Posting Permissions

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



Click Here to Expand Forum to Full Width