Better performance with compiled regex in Python

pattern = re.compile(r"brown (\w+)")

Available pattern functions: match, search, fullmatch, split, sub, findall, finditer and subn.

Each function has one less parameter for the pattern string.

pattern.sub(r"\1", "The brown fox jumps!")

Reference

re — Regular expression operations — Python 3.12.2 documentation