How to split URL without http:// using RegEx? 
Author Message
 How to split URL without http:// using RegEx?

Hi guys,

I'm looking for a regular expression to find and split up URL's with or
without http://, ftp:// etc. Basically I want it to work like this one:

^(.{2,6}://)?([^/]*)?(.*)

Although this one works only if the string sent to RegExp only contains the
URL to be split. I've tried to modify it to handle a string where the URL
should be found first and then split, but I failed. How should I do this?
Examples on how to find URLs including the protocol is easy to find, but I
haven't found any example on how to find URLs without the protocol.

Thanks for any kind of help.

Regards,
Jonah Olsson



Mon, 28 Nov 2005 00:16:51 GMT  
 How to split URL without http:// using RegEx?
Hello,


Quote:
> I'm looking for a regular expression to find and split up URL's

Untested:

http://www.mentalis.org/soft/classes.qpx
-> class "Url"

Regards,
Herfried K. Wagner
--
http://www.mvps.org/dotnet



Mon, 28 Nov 2005 00:22:20 GMT  
 How to split URL without http:// using RegEx?
Hi,

Thanks! I'll check it out.

/Jonah



Quote:
> Hello,


> > I'm looking for a regular expression to find and split up URL's

> Untested:

> http://www.mentalis.org/soft/classes.qpx
> -> class "Url"

> Regards,
> Herfried K. Wagner
> --
> http://www.mvps.org/dotnet



Mon, 28 Nov 2005 00:32:30 GMT  
 How to split URL without http:// using RegEx?
There are already classes in the CLR that parse URLs:

HttpRequest.Url
System.Uri

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
If the Truth hurts, wear it.



Quote:
> Hello,


> > I'm looking for a regular expression to find and split up URL's

> Untested:

> http://www.mentalis.org/soft/classes.qpx
> -> class "Url"

> Regards,
> Herfried K. Wagner
> --
> http://www.mvps.org/dotnet



Mon, 28 Nov 2005 01:34:10 GMT  
 How to split URL without http:// using RegEx?
Hi Kevin and thanks for your reply!

Yes, but they can't help me to extract each URL from a string. Or am I
missing something out? I believe I need RegEx for that..

/Jonah



Quote:
> There are already classes in the CLR that parse URLs:

> HttpRequest.Url
> System.Uri



Mon, 28 Nov 2005 06:03:07 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. about Regex.Split

2. url generation, is regex the only answer?

3. Getting HTTP header *without* d/l the entire document using inet control

4. get the total split words value by using the command split

5. HTTP: Download large files using HTTP and Internetcontrol

6. URL, Getting the url using asp

7. Invalid URL form or fully-qualified absolute URL was used

8. Calling http URL via Word VBA

9. Desperately need an HTTP URL encode routine

10. URL Directory Listing (HTTP)

11. URL HTTP Header

12. HTTP Get - URL Help

 

 
Powered by phpBB® Forum Software