Web Analytics Made Easy -
StatCounter String help - CodingForum

Announcement

Collapse
No announcement yet.

String help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • String help

    I have a string from window.location.search and would like to replace every occurence of a character in that word with another character.

    Example: http://www.sunyrockland.edu/library/librarian2.htm?subject=Question&print_blank_fields=1&title=Question&print_blank_fields=1&YourName=kh ksd+sdfosdf&status=student&[email protected]&[email protected]&subject=Test&Question=Test+as+to+what +needs+to+get+done+on+this+form.

    I would like to replace all the + with a space. How would I go about doing that?

    I used string.replace() to do this but only does it for the first +. In a loop it does it for every + after the first = and before the first &. I want it for all +.

  • #2
    I thin this should do it....

    var pattern = /\+/ig;
    var newString = myString.replace(pattern," ");
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

    Comment

    Working...
    X