Skip to content

Commit

Permalink
Update Tools/clinic/libclinic/utils.py
Browse files Browse the repository at this point in the history
  • Loading branch information
erlend-aasland authored Jan 14, 2024
1 parent 3c708fd commit a13702b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Tools/clinic/libclinic/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ def create_regex(
) -> re.Pattern[str]:
"""Create a regex object for matching marker lines."""
group_re = r"\w+" if word else ".+"
pattern = r"{}({}){}"
before = re.escape(before)
after = re.escape(after)
pattern = fr"{before}({group_re}){after}"
if whole_line:
pattern = "^" + pattern + "$"
pattern = pattern.format(re.escape(before), group_re, re.escape(after))
pattern = fr"^{pattern}$"
return re.compile(pattern)

0 comments on commit a13702b

Please sign in to comment.