Pattern vocabulary and raw strings
Regular expressions describe text using literals, character classes, quantifiers and grouping. In Python, raw string literals such as r"\d+" reduce conflicts between Python string escaping and regex escaping. A dot means any character except newline under default behavior, so a literal dot needs escaping or a character class. r"\d{3}" matches three digit characters, while r"\." matches a literal dot; [0-9] is an explicit ASCII digit class when that exact restriction is part of the log format contract. Understanding the two layers of escaping prevents patterns from changing meaning before the regex engine receives them and helps you choose precise character rules rather than accepting broader Unicode or punctuation behavior unintentionally in a parser used for automation. Writing an unescaped dot when a literal dot is intended matches unexpected characters; inspect near-miss examples and use raw strings or explicit escaping rather than trusting a pattern because it works on one positive fixture supplied by its author today.
r"\d{3}" matches three digit characters, while r"\." matches a literal dot; [0-9] is an explicit ASCII digit class when that exact restriction is part of the log format contract.Understanding the two layers of escaping prevents patterns from changing meaning before the regex engine receives them and helps you choose precise character rules rather than accepting broader Unicode or punctuation behavior unintentionally in a parser used for automation.
Writing an unescaped dot when a literal dot is intended matches unexpected characters; inspect near-miss examples and use raw strings or explicit escaping rather than trusting a pattern because it works on one positive fixture supplied by its author today.