code: def regex_matches(
      doclike: types.DocLike,
      pattern: str | Pattern,
      *,
      alignment_mode: Literal[
          "strict", "contract", "expand"
      ] = "strict",
  ) -> Iterable[Span]:
      """
      Extract ``Span`` s from a document or sentence whose full texts match against
      a regular expression ``pattern``.
  
      Args:
          doclike
          pattern: Valid regular expression against which to match document text,
              either as a string or compiled pattern object.
          alignment_mode: How character indices of regex matches snap to spaCy token
              boundaries. If "strict", only exact alignments are included (no snapping);
              if "contract", tokens completely within the character span are included;
              if "expand", tokens at least partially covered by the character span
              are included.
  
      Yields:
          Next matching ``Span``.
      """
      for match in re.finditer(pattern, doclike.text):
          start_char_idx, end_char_idx = match.span()
          span = doclike.char_span(
              start_char_idx, end_char_idx, alignment_mode=alignment_mode  # type: ignore
          )
          # Doc.char_span() returns None if character indices don’t map to a valid span
          if span is not None:
              yield span
  
file_path: textacy/src/textacy/extract/matches.py
imports: from __future__ import annotations
  import re
  from typing import Callable, Iterable, Literal, Optional, Pattern, Union
  from spacy.matcher import Matcher
  from spacy.tokens import Span
  from ..None import constants, errors, types
label_desc: Use image node_id 3 for calling a global function with example usage: regex_matches(doclike, pattern) without return types