[Python-ideas] Give regex operations more sugar

Oleg Broytman phd at phdru.name
Wed Jun 13 09:01:53 EDT 2018

On Wed, Jun 13, 2018 at 07:06:09PM +0800, Ken Hilton <kenlhilton at gmail.com> wrote:
> Regexes are really useful in many places, and to me it's sad to see the
> builtin "re" module having to resort to requiring a source string as an
> argument. It would be much more elegant to simply do "s.search(pattern)"
> than "re.search(pattern, s)".

pat_compiled = re.compile(pattern)

> I suggest building all regex operations into the str class itself, as well
> as a new syntax for regular expressions.

   There are many different regular expression implementation (regex,
re2). How to make ``s.search(pattern)`` work with all of them?

> Thoughts?
> Sincerely,
> Ken;

    Oleg Broytman            https://phdru.name/            phd at phdru.name
           Programmers don't die, they just GOSUB without RETURN.

More information about the Python-ideas mailing list