Why re.match()?
Lie Ryan
lie.1296 at gmail.com
Fri Jul 3 12:34:49 EDT 2009
Steven D'Aprano wrote:
> On Thu, 02 Jul 2009 11:19:40 +0000, kj wrote:
>
>> I'm sure that it is possible to find cases in which the *current*
>> implementation of re.search() would be inefficient, but that's because
>> this implementation is perverse, which, I guess, is ultimately the point
>> of my original post. Why privilege the special case of a
>> start-of-string anchor?
>
> Because wanting to see if a string matches from the beginning is a very
> important and common special case.
>
I find the most oddest thing about re.match is that it have an implicit
beginning anchor, but not implicit end anchor. I thought it was much
more common to ensure that a string matches a certain pattern, than just
matching the beginning. But everyone's mileages vary.
More information about the Python-list
mailing list