Definitive guide for Regex

Barry Scott barry at barrys-emacs.org
Thu Sep 30 16:59:08 EDT 2021



> On 30 Sep 2021, at 19:35, dn via Python-list <python-list at python.org> wrote:
> 
> On 01/10/2021 06.16, Barry Scott wrote:
>> 
>> 
>>> On 30 Sep 2021, at 12:29, Shaozhong SHI <shishaozhong at gmail.com> wrote:
>>> 
>>> Dear All,
>>> 
>>> I am trying to look for a definitive guide for Regex in Python.
>>> Can anyone help?
>> 
>> Have you read the python docs for the re module?
> 
> 
> I learned from Jeffrey Friedl's book "Mastering Regular Expressions",
> but that was in a land far away, last century, and under a different
> language (and the original version - I see it's now up to its third
> edition).
> 
> Despite their concise exercise of power (and the fact that in my
> Python-life I've never been put into a corner where I absolutely must
> use one), I'm no longer a fan...

Agreed, regex is the last tool I reach for in python code.
I find I use split() a lot to break up strings for processing.
But there are cases where a regex is the best tool for a particular job
and I then use the re module. But it costs in maintainability.

I speak as the author of a regex engine and know how to write scary
regex's when the need arises.

Barry


> -- 
> Regards,
> =dn
> -- 
> https://mail.python.org/mailman/listinfo/python-list
> 



More information about the Python-list mailing list