>>>>> "Girish" == Girish  <[EMAIL PROTECTED]> writes:

Girish> Hi Again,
Girish> I have a doubt, why do people use

Girish> if($html =~ /(<[^>]*>)/) {
Girish>         ....
Girish> }


Girish> instead of simple to use and understand
Girish> if($html =~ /(<.*?>)/) {
Girish>         ....
Girish> }
Girish> To extract HTML tags.

Well, the latter fails when \n appears within the tag, and the former
is easier to understand when coming from another regex language.  It's
probably also slightly faster.

Also, consider:

  "<abc>d<efg>h" =~ /<[^>]*>h/

matches "<efg>h", while

  "<abc>d<efg>h" =~ /<.*?>h/

ends up matching the entire string!  So ".*?" is not synonymous with
"this contains no instances of the closing delimiter", and I bet the
people that use the charclass version have gotten bitten by this
before and are now gunshy. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to