Skip to content

use raw string to escape regex sequence#129

Open
adehad wants to merge 1 commit intoscientifichackers:masterfrom
adehad:patch-1
Open

use raw string to escape regex sequence#129
adehad wants to merge 1 commit intoscientifichackers:masterfrom
adehad:patch-1

Conversation

@adehad
Copy link

@adehad adehad commented May 16, 2025

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant