[issue42353] Proposal: re.prefixmatch method (alias for re.match)

2022-02-05 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I am not convinced. What are examples of using re.match() instead of re.search()? How common is this type of errors? There are perhaps many millions of scripts which use re.match(), deprecating re.match() at any time in future would be very destructive, an

[issue42353] Proposal: re.prefixmatch method (alias for re.match)

2022-02-04 Thread Gregory P. Smith
Gregory P. Smith added the comment: What do other APIs in widely used languages do with regex terminology? We appear to be the only popular language who anchors to the start of a string with an API named "match". libpcre C: uses "match" to mean what we call "search" - https://www.pcre.org/

[issue42353] Proposal: re.prefixmatch method (alias for re.match)

2022-02-04 Thread Gregory P. Smith
Change by Gregory P. Smith : -- keywords: +patch pull_requests: +29314 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/31137 ___ Python tracker

[issue42353] Proposal: re.prefixmatch method (alias for re.match)

2022-02-04 Thread Gregory P. Smith
Change by Gregory P. Smith : -- assignee: -> gregory.p.smith versions: +Python 3.11 -Python 3.10 ___ Python tracker ___ ___ Python-

[issue42353] Proposal: re.prefixmatch method (alias for re.match)

2020-11-14 Thread Matthew Suozzo
Matthew Suozzo added the comment: > It just won't work unless you add explicit ".*" or ".*?" at the start of the > pattern But think of when regexes are used for validating input. Getting it to "just work" may be over-permissive validation that only actually checks the beginning of the inpu

[issue42353] Proposal: re.prefixmatch method (alias for re.match)

2020-11-14 Thread Gregory P. Smith
Gregory P. Smith added the comment: My point is that re.match is a common bug when people really want re.search. re.prefixmatch makes it explicit and non-confusing and thus unlikely to be used wrong or misunderstood when read or reviewed. The term "match" when talking about regular expressio

[issue42353] Proposal: re.prefixmatch method (alias for re.match)

2020-11-14 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I seen a code which uses re.search() with anchor ^ instead of re.match(), but I never seen a code which uses re.match() instead of re.search(). It just won't work unless you add explicit ".*" or ".*?" at the start of the pattern, and it is a clear indicati

[issue42353] Proposal: re.prefixmatch method (alias for re.match)

2020-11-14 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- components: +Regular Expressions nosy: +ezio.melotti, mrabarnett ___ Python tracker ___ ___

[issue42353] Proposal: re.prefixmatch method (alias for re.match)

2020-11-13 Thread Gregory P. Smith
New submission from Gregory P. Smith : A well known anti-pattern in Python is use of re.match when you meant to use re.search. re.fullmatch was added in 3.4 via https://bugs.python.org/issue16203 for similar reasons. re.prefixmatch would be similar: we want the re.match behavior, but want th