[Python-ideas] Give regex operations more sugar

Eric Fahlgren ericfahlgren at gmail.com
Wed Jun 13 18:59:29 EDT 2018


On Wed, Jun 13, 2018 at 3:54 PM MRAB <python at mrabarnett.plus.com> wrote:

> Would it check first-to-last or longest-to-shortest? I think that
> longest-to-shortest would be the most useful.
>
>  >>> old = ('cat', 'cats')
>  >>> new = ('mouse', 'mice')
>  >>>
>  >>> # First-to-last.
>  >>> 'cats'.replace(old, new)
> 'mouses'
>  >>>
>  >>> # Longest-to-shortest.
>  >>> 'cats'.replace(old, new)
> 'mice'
>

​I would expect left-to-right, and leave the programmer to get their mouse
in order.​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180613/a12f6a8f/attachment.html>


More information about the Python-ideas mailing list