To match one href key/value pairs per line:

while (<>) {
    if (/LinkArea=\"MoreHeadlines\"\>/) {
      print "$1\n", if (/href\=\"(\w+)\"\s/);
    }
}

...though this does assume that you'd only have one
href key and value per line after the "MoreHeadlines"
match.  If it's possible to have multiple per line,
a more robust solution would include possibly splitting
on the space char, matching and storing the href key/value
pair into an array or other data structure.

jab

On Sun, 23 Feb 2003, Chris Knipe wrote:

> Date: Sun, 23 Feb 2003 15:04:47 +0200
> From: Chris Knipe <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Subject: Stupid regex.. I'm going to kick myself...
>
> Lo all,
>
> I'm doing something *really* stupid... Please kick me...
>
> while (<>) {
>     if ($_ =~ /LinkArea="MoreHeadlines">/) {
>       ($URL) = $_ =~ /href="($.)"/;
>       print "$URL\n";
>     }
> }
>
> I have a URL...
>
> <a id="something" href="something" target="something"
> LinkArea="MoreHeadlines">test</a>
>
> Everything is randomly generated. Hence, I want to extract anything
> specified in the href="" field... So, after doing extensive reading, I found
> that I am indeed looking for /href="($.)"/  However, I cannot seem to
> extract this into a separated variable...
>
> What am I doing wrong??
>
> --
> me
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

--------
Be straight and to the point. Don't waste others' time.
Do your homework before you ask for help.

--Unknown


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to