SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict isuru's Avatar
    Join Date
    Nov 2000
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    search and replace in javascript

    Could someone please tell me how to search and replace in javascript. I want to search for:

    a "+" in a varaible and replace it with %2B

    and search for a "&" and replace it with %26

    I'd be very grateful if someone could help me out

    thanks

  2. #2
    SitePoint Member
    Join Date
    May 2001
    Location
    ON, Canada
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you need to escape characters in JavaScript simply use the escape function:

    str=escape(str); it will apply URL encoding rules which seems what you want.
    Regards,
    Alex Osokin - CTO

    The Web Hosting Portal http://www.findsp.com
    Hosting Forums: http://www.findsp.com/forum
    Web Hosting Newsletter: http://www.findsp.com/hosting/newsletter

  3. #3
    SitePoint Addict isuru's Avatar
    Join Date
    Nov 2000
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot for your help Alex
    I'll try them now


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
  •