Return a collection of the elements matching the regex

@deprecated replaced by self::capture, to be removed in 3.0

@param string $regex
@param int $offset
@param int $flags

@throws Exception If the regex failed

@return MapInterface<scalar, self>
771106
public function getMatches(
        string $regex,
        int $offset = 0,
        int $flags = self::PREG_NO_FLAGS
    ): MapInterface {
        return $this->capture($regex, $offset, $flags);
    }
188476
private function matchUri(string $regex, string $uri): ?array
    {
        if (preg_match_all('/' . $regex . '/', $uri, $uriMatches)) {
            $uriMatches = array_filter($uriMatches, function ($key) {
                if (is_string($key)) {
                    return true;
                }

                return false;
            }, ARRAY_FILTER_USE_KEY);

            $uriMatches = array_map(function ($match) {
                return $match[0];
            }, $uriMatches);

            return $uriMatches;
        }

        return null;
    }
1074919
public static function grep(array $arr, string $pattern, int $flags = 0): array
    {
        return Strings::pcre('\preg_grep', [$pattern, $arr, $flags]);
    }
811563
public static function custom($check, $regex = null)
    {
        if ($regex === null) {
            static::$errors[] = 'You must define a regular expression for Validation::custom()';

            return false;
        }

        return static::_check($check, $regex);
    }
1197939
public function regex($regex, $error) {
        if ($this->_exist) {
            array_push($this->_constraints, ['type' => self::REGEX, 'value' => $regex, 'message' => $error]);
        }

        return $this;
    }
545894
@Deprecated
    public PactDslJsonArray stringMatcher(String regex) {
      generators.addGenerator(Category.BODY, rootPath + appendArrayIndex(1), new RandomStringGenerator(10));
      stringMatcher(regex, new Generex(regex).random());
      return this;
    }
545412
private function _regexMatch(string $pattern, int &$offset)
    {
        $idx = $offset;
        if (!preg_match($pattern, substr($this->_dn, $idx), $match)) {
            return null;
        }
        $idx += strlen($match[0]);
        $offset = $idx;
        return end($match);
    }
826394
protected function findFilesAsSplFileInfo(string $regex, string $path) {
		
		$objects = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator($path), 
			RecursiveIteratorIterator::SELF_FIRST
		);
		
		$filter = new RegexIterator($objects, $regex);
		$map = [];
		
		foreach ($filter as $entry) {
			$map[] = $entry;
		}
		
		return count($map) > 0 ? $map : [];
	}
835789
public static Pattern get(String regex, int flags) {
		final RegexWithFlag regexWithFlag = new RegexWithFlag(regex, flags);

		Pattern pattern = POOL.get(regexWithFlag);
		if (null == pattern) {
			pattern = Pattern.compile(regex, flags);
			POOL.put(regexWithFlag, pattern);
		}
		return pattern;
	}
1243490
public function regex(string $regex) : Text
    {
        return $this->pipe(
            self::predicate(
                function ($value) use ($regex) {
                    return preg_match($regex, $value) === 1;
                },
                "does not match $regex"
            )
        );
    }
1237921
public static function glob(string $pattern, int $flags = 0): array
    {
        $pattern = Path::clean($pattern);

        if (strpos($pattern, '**') === false) {
            $files = glob($pattern, $flags);
        } else {
            $position = strpos($pattern, '**');
            $rootPattern = substr($pattern, 0, $position - 1);
            $restPattern = substr($pattern, $position + 2);
            $patterns = [$rootPattern . $restPattern];
            $rootPattern .= DIRECTORY_SEPARATOR . '*';

            while ($dirs = glob($rootPattern, GLOB_ONLYDIR)) {
                $rootPattern .= DIRECTORY_SEPARATOR . '*';

                foreach ($dirs as $dir) {
                    $patterns[] = $dir . $restPattern;
                }
            }

            $files = [];

            foreach ($patterns as $pat) {
                $files[] = static::glob($pat, $flags);
            }

            $files = array_merge(...$files);
        }

        $files = array_unique($files);

        sort($files);

        return $files;
    }
423013
public function match($regexp, $flag = PREG_PATTERN_ORDER, $offset = 0)
    {
        if ((bool) preg_match_all($regexp, $this->subject, $matches, $flag, $offset) === false) {
            return;
        }

        return $matches;
    }
717178
private function replaceTokensWithRegexCaptureGroups($regex)
    {
        $tokenRegex = self::TOKEN_REGEX;

        return preg_replace_callback(
            self::PLACEHOLDER_REGEXP,
            array($this, 'replaceTokenWithRegexCaptureGroup'),
            $regex
        );
    }
723784
public function find(string $pattern, int $flags = 0): Collection
    {
        $files = glob($this->path.'/'.$pattern, $flags);
        foreach ($files as $index => $file) {
            if (is_dir($file)) {
                $files[$index] = new self($file);
            } else {
                $files[$index] = new File($file);
            }
        }

        return new Collection($files);
    }
61213
public static function split(string $subject, string $pattern, int $flags = 0): array
    {
        return static::pcre('\preg_split', [$pattern, $subject, -1, $flags | PREG_SPLIT_DELIM_CAPTURE]);
    }
718602
public static Predicate<String> matchesRegex(final String regex) {
		final Pattern pattern = Pattern.compile(regex);
		return matchesRegex(pattern);
	}
631975
public function getMethodsByPattern($regex)
    {
    	$methods    = parent::getMethods();
    	$moufMethods = array();
    	foreach ($methods as $method) {
    		if (preg_match("/$regex/", $method->getName())) {
    			$moufMethods[$method->getName()] = new MoufReflectionMethod($this, $method->getName());
    		}
    	}
    
    	return $moufMethods;
    }