in reply to Grabbing meta tag info

small fix:

my $line = '<META NAME="TITLE" CONTENT="Page Title Here">'; $line =~ /<meta name="title" content="([^"]+)">/i; print $1; __END__ Page Title Here

If you do more html-processing than that, consider to use a readymade module instead of regexp'ing your way through it.

regards,
tomte


Hlade's Law:

If you have a difficult task, give it to a lazy person --
they will find an easier way to do it.

Replies are listed 'Best First'.
Re: Re: Grabbing meta tag info
by allolex (Curate) on Jun 19, 2003 at 17:28 UTC

    If you do more html-processing than that, consider to use a readymade module instead of regexp'ing your way through it.

    Yes, I can definitely agree with that, but if you do want to take your regex route, you might want to use a zero-width positive look-behind assertion like /(?<=<meta)content=([^"]+)/ to decrease the likelihood it will break if the tag attributes are not in the same order. :)

    --
    Allolex