code: def regex_strategy(regex, fullmatch):
      if not hasattr(regex, "pattern"):
          regex = re.compile(regex)
  
      is_unicode = isinstance(regex.pattern, text_type)
  
      parsed = sre_parse.parse(regex.pattern, flags=regex.flags)
  
      if not parsed:
          if is_unicode:
              return st.text()
          else:
              return st.binary()
  
      if is_unicode:
          base_padding_strategy = st.text()
          empty = st.just("")
          newline = st.just("\n")
      else:
          base_padding_strategy = st.binary()
          empty = st.just(b"")
          newline = st.just(b"\n")
  
      right_pad = base_padding_strategy
      left_pad = base_padding_strategy
  
      if fullmatch:
          right_pad = empty
      elif parsed[-1][0] == sre.AT:
          if parsed[-1][1] == sre.AT_END_STRING:
              right_pad = empty
          elif parsed[-1][1] == sre.AT_END:
              if regex.flags & re.MULTILINE:
                  right_pad = st.one_of(
                      empty, st.builds(operator.add, newline, right_pad)
                  )
              else:
                  right_pad = st.one_of(empty, newline)
      if fullmatch:
          left_pad = empty
      elif parsed[0][0] == sre.AT:
          if parsed[0][1] == sre.AT_BEGINNING_STRING:
              left_pad = empty
          elif parsed[0][1] == sre.AT_BEGINNING:
              if regex.flags & re.MULTILINE:
                  left_pad = st.one_of(
                      empty, st.builds(operator.add, left_pad, newline)
                  )
              else:
                  left_pad = empty
  
      base = base_regex_strategy(regex, parsed).filter(regex.search)
  
      return maybe_pad(regex, base, left_pad, right_pad)
  
imports: from __future__ import absolute_import, division, print_function
  import operator
  import re
  import sre_constants
  import sre_parse
  import sys
  import hypothesis.strategies
  from hypothesis import reject
  from hypothesis.internal.charmap import as_general_categories, categories
  from hypothesis.internal.compat import PY3, hrange, hunichr, int_to_byte, text_type
label_desc: Use image node_id 7 for calling a global function with example usage: regex_strategy(regex, fullmatch) and returns: maybe_pad, st, st