Regular Expressions to find URL's in text

Discussion in 'ASP General' started by SROSeaner, Oct 8, 2004.

  1. SROSeaner

    SROSeaner Guest

    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?
    SROSeaner, Oct 8, 2004
    #1
    1. Advertising

  2. SROSeaner

    David Morgan Guest

    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:...
    > 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?
    David Morgan, Oct 8, 2004
    #2
    1. Advertising

  3. SROSeaner

    Larry Bud Guest

    SROSeaner <> wrote in message news:<>...
    > 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?
    Larry Bud, Oct 8, 2004
    #3
  4. SROSeaner

    SROSeaner Guest

    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:<>...
    > > 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?
    >
    SROSeaner, Oct 11, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay Douglas
    Replies:
    0
    Views:
    593
    Jay Douglas
    Aug 15, 2003
  2. Mark
    Replies:
    0
    Views:
    297
  3. Replies:
    2
    Views:
    307
  4. Jimbo
    Replies:
    3
    Views:
    1,568
    Walter Overby
    May 1, 2010
  5. Noman Shapiro
    Replies:
    0
    Views:
    220
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page