Go

Go

By DeepSource

Simplify regular expression by using raw string literal SCC-S1007

Anti-pattern
Autofix

Raw string literals use backticks (`) instead of quotes (") and thus, do not support any escape sequences. This means that the backslash (\) can be used freely, without escaping.

Since regular expressions have their escape sequences, raw strings can improve their readability.

Examples

Bad practice

regexp.Compile("\\A(\\w+) profile: total \\d+\\n\\z")

Recommended

regexp.Compile(`\A(\w+) profile: total \d+
\z`)