How to escape strings for re.finditer?

Weatherby,Gerard gweatherby at uchc.edu
Tue Feb 28 20:01:48 EST 2023


Regex is fine if it works for you. The critiques – “difficult to read” –are subjective. Unless the code is in a section that has been profiled to be a bottleneck, I don’t sweat performance at this level.

For me, using code that has already been written and vetted is the preferred approach to writing new code I have to test and maintain. I use an online regex tester, https://pythex.org, to get the syntax write before copying pasting it into my code.

From: Python-list <python-list-bounces+gweatherby=uchc.edu at python.org> on behalf of Jen Kris via Python-list <python-list at python.org>
Date: Tuesday, February 28, 2023 at 1:11 PM
To: Thomas Passin <list1 at tompassin.net>
Cc: python-list at python.org <python-list at python.org>
Subject: Re: How to escape strings for re.finditer?
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

Using str.startswith is a cool idea in this case.  But is it better than regex for performance or reliability?  Regex syntax is not a model of simplicity, but in my simple case it's not too difficult.




More information about the Python-list mailing list