I am trying to replace the /'s in an URL with %2F
So if the URL was
http://www.netscape.com/sports/
I want it to be
http:%2F%2Fwww.netscape.com%2Fsports%2F
To do this I am trying the following JavaScript
str="http://www.netscape.com/sports/"
replaceStr="%2F"
regExp = /\//g
str2=str.replace(regExp, replaceStr)
and it doesn't work.
If I replace, say the http - it works fine - so there is something
wrong with the regular Expression.
I have also tried:
delim = "/g"
regExpValue = "\/"
regExp = eval ("/" + regExpValue + delim)
and that didn't work either.
I receive no errors - but nothing is replaced.
I did get the following to replace just the first /
str2=str.replace("\/", "%2F")
but would liek to replace all the /'s