Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Regular Expressions to find URL's in text

Reply
Thread Tools

Regular Expressions to find URL's in text

 
 
SROSeaner
Guest
Posts: n/a
 
      10-08-2004
I am working on an ASP page that parses text using the VBScript.RegExp
regular expression object. My reg expression right now is as follows:

[a-z]+\.[a-z]+\.[a-z]+/

And if find URL's no problem like: windowsupdate.microsoft.com,
www.cnn.com, etc.

But I need to also find any URL, like these:

www.amazon.com/books/atoz/index.html
OR
msdn.microsoft.com/newsgroups/default.aspx

Some URL with a deeper path than something.something.com if that makes
sense. Any ideas?
 
Reply With Quote
 
 
 
 
David Morgan
Guest
Posts: n/a
 
      10-08-2004
Nah...

What happens if someone writes a sentence and forgets to put a space between
the last word of the sentence, the period and the first word of the next
sentence?

URLs can take many forms and definitely don't need three parts. Some have
two some have four. What happens if someone puts in an IP address?

To get round the path/page name problem you should able to say where your
pattern matches anywhere in the string, not matches exactly.

Sorry to be the bearer of bad news.


"SROSeaner" <> wrote in message
news:FAE7D48A-2E06-424E-B469-...
> I am working on an ASP page that parses text using the VBScript.RegExp
> regular expression object. My reg expression right now is as follows:
>
> [a-z]+\.[a-z]+\.[a-z]+/
>
> And if find URL's no problem like: windowsupdate.microsoft.com,
> www.cnn.com, etc.
>
> But I need to also find any URL, like these:
>
> www.amazon.com/books/atoz/index.html
> OR
> msdn.microsoft.com/newsgroups/default.aspx
>
> Some URL with a deeper path than something.something.com if that makes
> sense. Any ideas?



 
Reply With Quote
 
 
 
 
Larry Bud
Guest
Posts: n/a
 
      10-08-2004
SROSeaner <> wrote in message news:<FAE7D48A-2E06-424E-B469->...
> I am working on an ASP page that parses text using the VBScript.RegExp
> regular expression object. My reg expression right now is as follows:
>
> [a-z]+\.[a-z]+\.[a-z]+/
>
> And if find URL's no problem like: windowsupdate.microsoft.com,
> www.cnn.com, etc.
>
> But I need to also find any URL, like these:
>
> www.amazon.com/books/atoz/index.html
> OR
> msdn.microsoft.com/newsgroups/default.aspx
>
> Some URL with a deeper path than something.something.com if that makes
> sense. Any ideas?


Why don't you just parse it to the first / character, and see if that conforms?
 
Reply With Quote
 
SROSeaner
Guest
Posts: n/a
 
      10-11-2004
Thanks for your help. I got my parser to get all URL's in many forms
including IP addresses all from a disorganized html file. It is possible,
just a bugger to get going.

"Larry Bud" wrote:

> SROSeaner <> wrote in message news:<FAE7D48A-2E06-424E-B469->...
> > I am working on an ASP page that parses text using the VBScript.RegExp
> > regular expression object. My reg expression right now is as follows:
> >
> > [a-z]+\.[a-z]+\.[a-z]+/
> >
> > And if find URL's no problem like: windowsupdate.microsoft.com,
> > www.cnn.com, etc.
> >
> > But I need to also find any URL, like these:
> >
> > www.amazon.com/books/atoz/index.html
> > OR
> > msdn.microsoft.com/newsgroups/default.aspx
> >
> > Some URL with a deeper path than something.something.com if that makes
> > sense. Any ideas?

>
> Why don't you just parse it to the first / character, and see if that conforms?
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expressions: Find part of a string Jermaine Ruby 4 06-04-2009 10:09 PM
find and replace with regular expressions chrispoliquin@gmail.com Python 6 08-01-2008 10:55 AM
find next occurence, regular expressions John Griffiths Ruby 2 12-30-2007 01:35 PM
Regular Expressions for Find and Replace Mark ASP .Net 0 05-18-2004 01:24 PM
Add custom regular expressions to the validation list of available expressions Jay Douglas ASP .Net 0 08-15-2003 10:19 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57