REGULAR-EXPRESSIONS5 MIN READ
Escaping battlecards for regex review
Recall the safest escaping move for common regex metacharacter situations.
Literal dot How do you match a literal dot in regex syntax? Escape it as \\. or place it in a character class like [.] when that is clearer. The dot is a metacharacter outside a class, so the regex engine needs a literal instruction. Layer compare Regex literal vs string constructor: why do backslashes differ? Inspect regex.source when confused; it shows what the engine compiled. Hyphen in class Do I always need to escape - inside []? A teammate is writing a class for letters, digits, and hyphen. Your line Either escape it as \- or place it first…
Read the full lesson
Sign up free — one personalized lesson every day, matched to your role and goals.
Already have an account? Sign in