Page MenuHomeDevCentral

Declare regular expression patterns as raw Python strings
ClosedPublic

Authored by dereckson on Jul 4 2026, 12:09.
Tags
None
Referenced Files
F44188276: D4112.diff
Sat, Aug 15, 20:45
F44178619: D4112.id10787.diff
Sat, Aug 15, 19:03
Unknown Object (File)
Wed, Aug 12, 21:26
Unknown Object (File)
Wed, Aug 12, 17:56
Unknown Object (File)
Wed, Aug 12, 17:54
Unknown Object (File)
Mon, Aug 10, 22:07
Unknown Object (File)
Sun, Aug 9, 12:03
Unknown Object (File)
Thu, Aug 6, 17:38
Subscribers
None

Details

Summary

This follow current Python style best practice when no escape
is needed, and avoid a syntax warning when the string escapes
a character only to be escaped for regexp, not for Python strings.

Fixes the following issue on Python 3.12+:

/usr/local/bin/shell:138: SyntaxWarning: invalid escape sequence '\|'
  matches = re.search("(.*)\|(.*)", variable)

Diff Detail

Repository
rOPS Nasqueron Operations
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dereckson created this revision.
dereckson edited the summary of this revision. (Show Details)
This revision is now accepted and ready to land.Jul 4 2026, 12:14