Re: startswith() and endswith() for re's would be more intuitive



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.
.



Relevant Pages