realbasic-nug
[Top] [All Lists]

Re: finding links with RegEx?

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: finding links with RegEx?
From: Charles Yeomans <yeomans at desuetude dot com>
Date: Wed, 27 Feb 2002 18:03:45 -0500

On Wednesday, February 27, 2002, at 05:42  PM, Noah Desch wrote:


On Wednesday, February 27, 2002, at 05:35  PM, Thomas Reed wrote:

Does anyone have an example of how to find links in HTML files using
RegEx?  I'm not all that knowledgeable in regular expressions, and I'm
curious about whether someone else has already invented this particular
wheel...

Note that I need to find any kind of link to an external file -- such as <A HREF="link">, <IMG SRC="link">, <BODY BACKGROUND="link">, etc. And I
need to be able to quickly and easily isolate the "link" text.

I'm no expert but the search pattern would be something like

"SRC=""(.)"""

and

"HREF=""(.)"""

(sorry, I don't know how to search for both at the same time)
and then RegexMatch.Subexpression(1) would be the link URL.


Use the | operator to indicate alternatives. For instance, (SRC)|(HREF)=\"(.+)\" should catch both of th above choices.

Charles Yeomans




<Prev in Thread] Current Thread [Next in Thread>