ampy
ampy copied to clipboard
use raw string to escape regex sequence
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!