ampy icon indicating copy to clipboard operation
ampy copied to clipboard

use raw string to escape regex sequence

Open adehad opened this issue 7 months ago • 0 comments

This addresses the SyntaxWarning for 'invalid escape sequence'

For example in a Python REPL or otherwise:

import re

>>> match1 = re.match(r"^COM(\d+)$", "COM124")
>>> match1.group()
'COM124'
>>> match2 = re.match("^COM(\d+)$", "COM123")
<stdin>:1: SyntaxWarning: invalid escape sequence '\d'
>>> match2.group()
'COM123'

It appears that at least of Python v3.12.6 it has not resulted in an error. But perhaps worth fixing!

adehad avatar May 16 '25 10:05 adehad