Regular Expression for URL

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

  1. SROSeaner

    SROSeaner Guest

    I am working on an ASP page which looks in a set of text for web page URLs.

    Using the VBScript.RegExp regular expression object, I have this regular
    expression:

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

    And it works well finding URL's such as: windowsupdate.microsoft.com,
    www.cnn.com, etc.

    However, I have been trying to modify it to ALSO find URL's like this:

    www.amazon.com/index/sell/ie6.html?val=1
    Or
    www.microsoft.com/windowsxp

    Any ideas?
     
    SROSeaner, Oct 8, 2004
    #1
    1. Advertising

  2. SROSeaner

    Lasse Edsvik Guest

    SROSeaner,


    Function LinkURL(stringa)
    Dim objRegExp, strTemp
    Set objRegExp = New RegExp

    objRegExp.IgnoreCase = True
    objRegExp.Global = True
    objRegExp.Pattern = "(\b(www\.|http\://)\S+\b)"
    strTemp = objRegExp.replace(stringa, "<A HREF='http://$1'
    class='orangelnk' TARGET='_new'>$1</A>")
    LinkURL = Replace(strTemp, "http://http://","http://")
    Set objRegExp = Nothing
    End Function



    "SROSeaner" <> wrote in message
    news:...
    > I am working on an ASP page which looks in a set of text for web page

    URLs.
    >
    > Using the VBScript.RegExp regular expression object, I have this regular
    > expression:
    >
    > [a-z]+\.[a-z]+\.[a-z]+/
    >
    > And it works well finding URL's such as: windowsupdate.microsoft.com,
    > www.cnn.com, etc.
    >
    > However, I have been trying to modify it to ALSO find URL's like this:
    >
    > www.amazon.com/index/sell/ie6.html?val=1
    > Or
    > www.microsoft.com/windowsxp
    >
    > Any ideas?
     
    Lasse Edsvik, Oct 8, 2004
    #2
    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. VSK
    Replies:
    2
    Views:
    2,303
  2. Replies:
    4
    Views:
    734
  3. Replies:
    0
    Views:
    365
  4. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    851
    Alan Moore
    Dec 2, 2005
  5. GIMME
    Replies:
    3
    Views:
    11,972
    vforvikash
    Dec 29, 2008
Loading...

Share This Page