code: def matches_re(regex, flags=0, func=None):
      r"""
      A validator that raises `ValueError` if the initializer is called
      with a string that doesn't match *regex*.
  
      :param str regex: a regex string to match against
      :param int flags: flags that will be passed to the underlying re function
          (default 0)
      :param callable func: which underlying `re` function to call (options
          are `re.fullmatch`, `re.search`, `re.match`, default
          is ``None`` which means either `re.fullmatch` or an emulation of
          it on Python 2). For performance reasons, they won't be used directly
          but on a pre-`re.compile`\ ed pattern.
  
      .. versionadded:: 19.2.0
      """
      fullmatch = getattr(re, "fullmatch", None)
      valid_funcs = (fullmatch, None, re.search, re.match)
      if func not in valid_funcs:
          raise ValueError(
              "'func' must be one of %s."
              % (
                  ", ".join(
                      sorted(
                          e and e.__name__ or "None"
                          for e in set(valid_funcs)
                      )
                  ),
              )
          )
  
      pattern = re.compile(regex, flags)
      if func is re.match:
          match_func = pattern.match
      elif func is re.search:
          match_func = pattern.search
      else:
          if fullmatch:
              match_func = pattern.fullmatch
          else:
              pattern = re.compile(r"(?:{})\Z".format(regex), flags)
              match_func = pattern.match
  
      return _MatchesReValidator(pattern, flags, match_func)
  
imports: from __future__ import absolute_import, division, print_function
  import re
  from ._make import _AndValidator, and_, attrib, attrs
  from .exceptions import NotCallableError
label_desc: Use image node_id 2 for calling a global function with example usage: matches_re(regex, flags, func) and returns: _MatchesReValidator