Max Power
06-30-2004, 06:44 PM
I am trying to convert a URL to a string. I am having problems with URL's that have spaces (" ") in them. Basically, I would like to replace any space in a URL with "%20". Here is an example:
http://www.domain.com/Site Name
I can convert this to a string like this:
{
strURL = "http://www.domain.com/Site Name";
strNewUrl = strUrl.replace(" ", "%20");
return (strNewURL); // returns "http://www.domain.com/Site%20Name"
}
However, if there are MULTIPLE spaces in the original URL, I don't know how to find and replace ALL of the spaces with a '%20'.
So, what would be the best way to have a function return
"http://www.domain.com/Another%20Site%20Name"
from "http://www.domain.com/Another Site Name" ??
Any ideas??? :eek:
http://www.domain.com/Site Name
I can convert this to a string like this:
{
strURL = "http://www.domain.com/Site Name";
strNewUrl = strUrl.replace(" ", "%20");
return (strNewURL); // returns "http://www.domain.com/Site%20Name"
}
However, if there are MULTIPLE spaces in the original URL, I don't know how to find and replace ALL of the spaces with a '%20'.
So, what would be the best way to have a function return
"http://www.domain.com/Another%20Site%20Name"
from "http://www.domain.com/Another Site Name" ??
Any ideas??? :eek: