Regular Expression to extract hyperlinks containing keyword

Posted on 2008-11-20
Last Modified: 2012-05-05
I need a regular expression that can be used in VB6, that extracts a hyperlink / URL from a html page or .txt document.  I need it to extraxt only links that contain a certain keyword or phrase, example: 'foo'
Question by:greg_white
    LVL 2

    Accepted Solution

    i think something like this
    (http://[^ ]*foo[^ ]*)

    Open in new window


    Author Comment

    That's close...

    It's stopping only when it finds a space:
    Example it catches this whole piece instead of stopping at the second quotes."/>

    In place of the quote could we put \"...

    Well I tried that and it works...

    LVL 2

    Expert Comment

    try this
    (http://[^ "]*foo[^ "]*)

    Open in new window


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
    In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
    The viewer will learn how to count occurrences of each item in an array.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now