(
    doclike: types.DocLike,
    pattern: str | Pattern,
    *,
    alignment_mode: str = "strict",  # Literal["strict", "contract", "expand"]
)
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``.
Extract ``Span`` s from a document or sentence whose full texts match against
    a regular expression ``pattern``.
Extract Span s from a document or sentence whose full texts match against a regular expression pattern .
def regex_matches(
    doclike: types.DocLike,
    pattern: str | Pattern,
    *,
    alignment_mode: str = "strict",  # Literal["strict", "contract", "expand"]
) -> 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
        )
        # Doc.char_span() returns None if character indices don’t map to a valid span
        if span is not None:
            yield span
def regex_matches ( doclike : types . DocLike , pattern : str | Pattern , * , alignment_mode : str = "strict" , # Literal["strict", "contract", "expand"] ) -> Iterable [ 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 ) # Doc.char_span() returns None if character indices don’t map to a valid span if span is not None : yield span