RE: How to avoid this greedy match?

2008-01-28 Thread Nagrale, Ajay
Hi,

I don't think '<' or '>' are meta characters in regular expression match.

"<>" is reserved for opening the files given at command line argument.

>>Aside from that, consider using [^<]* and [^>]* in place of .*
If we use "[^<]* and [^>]*", regular expression will fail to match pattern like 
"xxxzzz>>222<>" [Pattern having angular 
brackets beside 222.

As we don't know what can precede or succeed '222', it's better we don't give 
any restriction in the regular expression.

~Ajay

-Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of yitzle
Sent: Tuesday, January 29, 2008 11:53 AM
To: Nagrale, Ajay
Cc: News Howardz; beginners@perl.org
Subject: Re: How to avoid this greedy match?


I'm not sure how it works, but I think <> or \<\> is a RegEx reserved
character for word matching.
Aside from that, consider using [^<]* and [^>]* in place of .*

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: How to avoid this greedy match?

2008-01-28 Thread Nagrale, Ajay
Try out the following regular expression:

perl -e '$str = "...442226zzz222...";print 
"1=$1\n" if ($str =~ /.+(.*222.*)<\/script>/);'

The regeular expression is: .+