SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to replace "_" with spaces in a string of text?

    I have a string of text "hello_there_my_friends" and I need to use javascript to replace the "_" with spaces..

    Is there a function that lets me do this?
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    Los Angeles
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use this:

    replace("_", " ")

    only supported in javascript 1.2
    Do you have a career or job related web site?
    Earn 5 cents per click by joining our affiliate program.
    Click Here

  3. #3
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was unable to find any javascript functions called "replace". (except location.replace)

    Thanks.
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  4. #4
    Confirmed Halfwit
    Join Date
    Oct 1999
    Location
    Vancouver, BC, Canada
    Posts
    983
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    * bump *

    Anyone know how to do this?
    - A simple online WYSIWYG editor for HTML code snippets.
    - Managed Web Hosting - $3.95/month (resellers welcome)
    - Why pay more? $8.95 domains & $9.95 SSL certificates!

  5. #5
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <script type="text/javascript">

      
    myString = new String('hello_there_my_friends');

      
    rExp = /_/gi;

      
    newString = new String (' ');
      
    results myString.replace(rExpnewString);

      
    document.write(results);

    </script> 
    this will do ya


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
  •