Results 1 to 4 of 4

Thread: Javascript to replace plus sign

  1. #1
    Join Date
    Jan 2009
    Posts
    44

    Javascript to replace plus sign

    I have some text and using java script i need to replace the plus sign, so the question is Javascript to replace plus sign or any single character from a long text like for example :
    Code:
    firsttext+secondtext&thirdtext?fourthtext=firstvalue&firsttext+secondtext&thirdtext?fourthtext=secondvalue
    From this text i want to replace all the plus sign, '?' sign, '&' sign and '=' sign how do i do it? Please help...

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    Re: Javascript to replace plus sign

    You will have to write a java script code for each character, example :

    Code:
    replace("+", "text").
    replace("?", "text").
    replace("&", "text").
    replace("=", "text").

  3. #3
    Join Date
    Jan 2009
    Posts
    44

    Re: Javascript to replace plus sign

    Thanks for replying that quick, really appreciate your help, but i already this method, doesn't help. This only replaces the first occurrence of the sign with the text but the later one remains as it is. Any other method? Please help!

  4. #4
    Join Date
    May 2008
    Posts
    2,389

    Re: Javascript to replace plus sign

    Well did you try this method :


    Code:
    replace(/+/g, "text")
    replace(/?/g, "text")
    replace(/&/g, "text")
    replace(/=/g, "text")
    This might do the work...

Similar Threads

  1. Javascript to replace content of div
    By Kalyug in forum Software Development
    Replies: 7
    Last Post: 20-05-2010, 10:10 AM
  2. JavaScript - location.replace
    By Cordaro in forum Software Development
    Replies: 6
    Last Post: 13-05-2010, 11:55 PM
  3. javascript replace function not working
    By Cornnelius in forum Software Development
    Replies: 5
    Last Post: 13-05-2010, 12:12 AM
  4. Javascript to replace all double quotes
    By Amy Adams in forum Software Development
    Replies: 5
    Last Post: 12-05-2010, 10:15 AM
  5. How to replace HTML code using javascript
    By visioneye in forum Software Development
    Replies: 6
    Last Post: 11-05-2010, 11:38 PM

Tags for this Thread

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
  •  
Page generated in 1,714,021,640.45264 seconds with 16 queries