Gossamer Forum
Home : General : Perl Programming :

Regex Problems....

Quote Reply
Regex Problems....
Hi. I'm wondering if someone can help me here. I have been playing with making a news retrival script from clari.net. I have the following code that will grab the actual article from their site, and put it into an array;

Code:
my @grabbed_article = get($url);

my $start = 0;
my $article;
foreach my $line (@grabbed_article) {

if ($line =~ /\<H1\>/) { $start = 1; $article .= $line; }

if ($start) { $article .= $line; }

if ($line =~ /\<hr noshade vspace=5\>/) { last; }


}

The problem seems to be, that the part in red cuts in right at the top of the page....does anyone have any ideas why the regex in place there is doing that?

Thanks in advance.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Regex Problems.... In reply to
Why not just do:

Code:
my ($string) = get($url);
my ($wanted) = $string =~ /<H1>(.+?)<hr noshade vspace=5>/si;

Notice how you don't need to escape angular brackets either =)
Quote Reply
Re: [Paul] Regex Problems.... In reply to
Thanks Paul, it worked a treat Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!