re.sub regex won't match

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: re.sub regex won't match

Post by pythoncoder » Sun Oct 21, 2018 9:31 am

So (correct me if I'm wrong) the take-home from this is that ure has a limitation by design.

In CPython and MicroPython the string r'\n' contains two characters, '\' and 'n'. CPython's re module interprets these as a '\n' character while ure treats them literally.

I guess in most cases the workround is to avoid (or at least think hard about) r strings in ure regexes.
Peter Hinch
Index to my micropython libraries.

Post Reply