Gossamer Forum
Home : General : Perl Programming :

Regex Problem (:

Quote Reply
Regex Problem (:
I'm trying to do a match on a line from a page. At the moment I have;

$page_info =~ m,\<td\>\<font face=(.+?) size=(.+?)\>\&nbsp\;(.+?)\<\/td\>,i and $ID = $3;

The problem is, right after the 3rd (.+?) I have a </a>....however, this is not present on all the entries grabbed. I've tried doing stuff like this after it;

(\<\/a>?)

and severa lother combinations...however, none of them seem to work :-/ If I take out that code, and simply grab links that don't have the </a> in it, the regex works fine. I've never claimed to be great at regex....and I'm pretty stumped here Unsure

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!
Quote Reply
Re: [Andy] Regex Problem (: In reply to
Mmm have you taken the time to read "perlre" at perldoc.com?

You don't need to escape all the stuff you've escaped in that regex. You only escape meta-characters.

Using "and $ID = $3" at the end is also a bit obscure Crazy

Last edited by:

Paul: Dec 23, 2002, 6:45 AM
Quote Reply
Re: [Paul] Regex Problem (: In reply to
I've been reading through it....but it doesn't really help me :-/ Its been a busy week last week, maybe I should take some time off and relax for a bit. May be able to think a bit better then Unsure

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!
Quote Reply
Re: [Andy] Regex Problem (: In reply to
Code:
my ($ID) = $page_info =~ m,<td><font face=[^\s]+ size=[^>]+>&nbsp;(.+?)(?:</a>)?</td>,si

Try something like that. It can probably still be improved.
Quote Reply
Re: [Paul] Regex Problem (: In reply to
Worked out this oner too. Can't remember what the fix was that I made to it....this it was (a-z)? ... but I'm not definate Tongue

Thanks anyway :)

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 Problem (: In reply to
(a-z)? probably wasn't what you were thinking of ;)