Re: Perl 5's "non-greedy" matching can be TOO greedy!
[email protected] ((Randal L. Schwartz)) 14 Dec 2000 15:40:52 -0800
| Newsgroups | perl.perl6.language.regex |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "Deven" == Deven T Corzine <[email protected]> writes: Deven> I haven't even SEEN an example where the current behavior is Deven> actually preferable than my proposed behavior, have you? (And Deven> I'd expect at least a FEW, though I suspect there are probably Deven> more counterexamples.) If I want the leftmost B that is followed by the shortest number of characters to get to a D, I write /B.*?D/. The "leftmost" part keeps getting left out of regex discussions, and maybe that's why you're thrown off. But it's a pretty consistent overriding factor. If you want something odd like "not necessarily the leftmost", then you'll need to speak more. But "leftmost" is fundamental to the design of regex. Don't mess with that. Or don't call it a regex any more. -- 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!