SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    455
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Trimming A Javascript Variable

    I have a javascript variable var newLink = "Bob "; which comes from a xmlhttp.responseText.

    I could clean-up the string in my php script. I could also slice at " ,", but I'd like to know how to trim "Bob " with js.

    How is that done?

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    455
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    split(' ').join(''); did the trick. It's hard to how when there's a tailor made method and when some assembly is required as I learn javascript.

  3. #3
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    Here's an interesting page on a number of the different ways of trimming in javascript: http://blog.stevenlevithan.com/archi...rim-javascript

  4. #4
    SitePoint Evangelist
    Join Date
    Jun 2010
    Posts
    455
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank-you Immerse. Happy Holidays.


Bookmarks

Posting Permissions

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