startswith() and endswith() for re's would be more intuitive
John Salerno
johnjsal at NOSPAMgmail.com
Thu Sep 28 10:41:32 EDT 2006
Bruno Desthuilliers wrote:
> metaperl wrote:
>> I just finished answering a question in #python because someone tried
>> to match using ... well.. match()
>> but did not realize that match() is actually startswith() for regexps.
>
> Yet someone else that failed to read the Fine Manual(tm).
>
>> I suggest:
>> re.compile('blah').atstartof(string)
>> re.compile('blah').atendof(string)
>
> What's wrong with:
> re.search(r'^blah', somestring)
> re.search(r'blah$', somestring)
I think, since he even said himself that "match() is actually
startswith() for regexps", that he isn't complaining about the lack of
this feature, just that he wants a name change. Otherwise I'm not sure
what he wants.
More information about the Python-list
mailing list