code: def create_regex(
      before: str,
      after: str,
      word: bool = True,
      whole_line: bool = True,
  ) -> re.Pattern[str]:
      """Create a regex object for matching marker lines."""
      group_re = r"\w+" if word else ".+"
      before = re.escape(before)
      after = re.escape(after)
      pattern = rf"{before}({group_re}){after}"
      if whole_line:
          pattern = rf"^{pattern}$"
      return re.compile(pattern)
  
file_path: cpython/Tools/clinic/libclinic/utils.py
imports: import collections
  import hashlib
  import os
  import re
  import string
  from typing import Literal
label_desc: Use image node_id 3 for calling a global function with example usage: create_regex(before, after, word, whole_line) and returns: re