SPUG: Matching HTML Meta Tags
El JoPe Magnifico
jope-spug at jope.net
Mon Jul 23 01:51:59 CDT 2001
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/
More information about the spug-list
mailing list