How to escape strings for re.finditer?

Cameron Simpson cs at cskk.id.au
Mon Feb 27 19:36:45 EST 2023


On 28Feb2023 00:57, Jen Kris <jenkris at tutanota.com> wrote:
>Yes, that's it.  I don't know how long it would have taken to find that 
>detail with research through the voluminous re documentation.  Thanks 
>very much. 

You find things like this by printing out the strings you're actually 
working with. Not the original strings, but the strings when you're 
invoking `finditer` i.e. in your case, escaped strings.

Then you might have seen that what you were searching no longer 
contained what you were searching for.

Don't underestimate the value of the debugging print call. It lets you 
see what your programme is actually working with, instead of what you 
thought it was working with.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Python-list mailing list