# Path: pytube/exceptions.py
# class RegexMatchError(ExtractError):
#     """Regex pattern did not return any matches."""
# 
#     def __init__(self, caller: str, pattern: Union[str, Pattern]):
#         """
#         :param str caller:
#             Calling function
#         :param str pattern:
#             Pattern that failed to match
#         """
#         super().__init__(f"{caller}: could not find match for {pattern}")
#         self.caller = caller
#         self.pattern = pattern


import functools
import gzip
import json
import logging
import os
import re
import warnings
from typing import Any, Callable, Dict, List, Optional, TypeVar
from urllib import request
from pytube.exceptions import RegexMatchError
    from pytube import YouTube
        return self._elements[::-1]

    def generate_all(self):
        """Generate all items."""
        while True:
            try:
                next_item = next(self.gen)
            except StopIteration:
                break
            else:
                self._elements.append(next_item)


def regex_search(pattern: str, string: str, group: int) -> str:
    """Shortcut method to search a string for a given pattern.

    :param str pattern:
        A regular expression pattern.
    :param str string:
        A target string to search.
    :param int group:
        Index of group to return.
    :rtype:
        str or tuple
    :returns:
        Substring pattern matches.
    """
    regex = re.compile(pattern)
    results = regex.search(string)
    if not results:

# Path: pytube/exceptions.py
# class RegexMatchError(ExtractError):
#     """Regex pattern did not return any matches."""
# 
#     def __init__(self, caller: str, pattern: Union[str, Pattern]):
#         """
#         :param str caller:
#             Calling function
#         :param str pattern:
#             Pattern that failed to match
#         """
#         super().__init__(f"{caller}: could not find match for {pattern}")
#         self.caller = caller
#         self.pattern = pattern


# Path: pytube/helpers.py
import functools
import gzip
import json
import logging
import os
import re
import warnings
from typing import Any, Callable, Dict, List, Optional, TypeVar
from urllib import request
from pytube.exceptions import RegexMatchError
    from pytube import YouTube

        return self._elements[::-1]

    def generate_all(self):
        """Generate all items."""
        while True:
            try:
                next_item = next(self.gen)
            except StopIteration:
                break
            else:
                self._elements.append(next_item)


def regex_search(pattern: str, string: str, group: int) -> str:
    """Shortcut method to search a string for a given pattern.

    :param str pattern:
        A regular expression pattern.
    :param str string:
        A target string to search.
    :param int group:
        Index of group to return.
    :rtype:
        str or tuple
    :returns:
        Substring pattern matches.
    """
    regex = re.compile(pattern)
    results = regex.search(string)
    if not results:

        raise RegexMatchError(caller="regex_search", pattern=pattern)