SPUG: Matching HTML Meta Tags

Ron Didderon didderon at home.com
Mon Jul 23 02:09:22 CDT 2001


No, that makes perfect sense. Thank you for clearing that up.

-- Ryan

-----Original Message-----
From: owner-spug-list at pm.org [mailto:owner-spug-list at pm.org]On Behalf Of
El JoPe Magnifico
Sent: Sunday, July 22, 2001 11:52 PM
To: Parr, Ryan
Cc: 'spug-list at pm.org'
Subject: RE: SPUG: Matching HTML Meta Tags


On Sun, 22 Jul 2001, Parr, Ryan wrote:
> doesn't work:     $file =~
> /<meta\s+name\s*=\s*"keywords"\s+content\s*=\s*"(.*)?"\s*>/sig;
> does    work:     $file =~
> /<\s*meta\s+name\s*=\s*"keywords"\s+content\s*=\s*"(.*?)"\s*>/sig;
>
> I think this is pretty bizzare though. Is there anyone who could tell me
> why I need to match 0 or more whitespace character after < and before >?

That wasn't what made the difference.  Near the end of your pattern,
you switched from "(.*)?" to "(.*?)" -- the position of the question mark
changes its use as a modifier.  (.*)? is zero or one "greedy" matches,
whereas (.*?) is a single non-greedy match.  If it's not clear from that
quick explanation, just ask...
  -jp


 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/



 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
  Seattle Perl Users Group (SPUG) Home Page: http://www.halcyon.com/spug/





More information about the spug-list mailing list