Returns all matching groups for the given regex.
String and IRI equences are automatically escaped.

@param string $regex
@param string $expression
@param int $group
@return string[]
778810
public function getMatches( $regex, $expression, $group = 1 ) {
		if ( preg_match_all(
			'/' . $this->resolveMagic( $regex ) . '/',
			$this->escapeSequences( $expression ),
			$matches
		) ) {
			return $matches[$group];
		}

		return array();
	}
1030952
private function getRanges(string $text, string $regex): array
	{
		preg_match_all($regex, $text, $matches, PREG_OFFSET_CAPTURE);

		$ranges = array_map(function ($match) {
			return [$match[1], strlen($match[0])];
		}, $matches[0]);

		return $ranges;
	}
153582
protected function _filterAll($regex, $content, $i = 1, $key = '') {
		if (@preg_match_all($regex, $content, $matches) === false) {
			return false;
		}
		$result = isset($matches[$i]) ? $matches[$i] : $matches[0];
		if (isset($this->_callback['_all_'])) {
			foreach ($this->_callback['_all_'] as $filter) {
				$result = array_map($filter, $result);
			}
		}
		if ($key != '' && isset($this->_callback[$key])) {
			foreach ($this->_callback[$key] as $filter) {
				$result = array_map($filter, $result);
			}
		}
		return $result;
	}
744304
public static List<String> getStringsByRegex(final String text, final String regex) {

    Pattern pattern = Pattern.compile(regex);
    Matcher matcher = pattern.matcher(text);
    List<String> matchedStrings = new ArrayList<String>();
    while (matcher.find()) {
      matchedStrings.add(matcher.group(0));
    }
    return matchedStrings;
  }
19279
def regex_search(txt, rgx, ignorecase=False, multiline=False):
    '''
    
    '''
    flag = 0
    if ignorecase:
        flag |= re.I
    if multiline:
        flag |= re.M
    obj = re.search(rgx, txt, flag)
    if not obj:
        return
    return obj.groups()
190573
public function setConstraint($token, $regex)
    {
        $initPos = strpos($this->pattern, "{" . $token);

        if ($initPos !== false) {
            $endPos = strpos($this->pattern, "}", $initPos);
            $newPattern = substr_replace($this->pattern, "{" . "$token:$regex" . "}", $initPos, $endPos - $initPos + 1);
            $wildcards = $this->collector->getParser()->getWildcardTokens();
            $newPattern = str_replace(array_keys($wildcards), $wildcards, $newPattern);
            $this->setPatternWithoutReset($newPattern);
        }

        return $this;
    }
1312352
public function getDataRegexMatch(string $regex, $group = null, int $fill_size = 0)
    {
        $is_matched = preg_match($regex, $this->stringDataIsWaitingToBeParsed, $matches);

        if ($group !== null && $group >= 0) {
            if ($is_matched) {
                return $matches[$group] ?? '';
            } else {
                return '';
            }
        } else {
            if ($is_matched) {
                if ($group !== null) {
                    array_shift($matches);
                }
                return $matches ?: [];
            } else {
                return $fill_size > 0 ? array_fill(0, $fill_size, '') : $matches;
            }
        }
    }
175770
public static List<String> match(String pattern, String reg, int group) {

        List<String> matchGroups = new ArrayList<>();
        Pattern compile = Pattern.compile(reg);
        Matcher matcher = compile.matcher(pattern);
        if (group > matcher.groupCount() || group < 0)
            throw new IllegalGroupIndexException("Illegal match group :" + group);
        while (matcher.find()) {
            matchGroups.add(matcher.group(group));
        }
        return matchGroups;
    }
1345872
private function getOptionByRegExpr(string $pattern): array
    {
        $purgedArgs = $this->getRawArgs(true);
        return preg_grep("/" . $pattern . "/", $purgedArgs);
    }
959180
public static List<String> findAllGroup1(String regex, CharSequence content) {
		return findAll(regex, content, 1);
	}
889797
public static Expression regexpContains(String expression, String pattern) {
        return regexpContains(x(expression), pattern);
    }
198495
protected function getGroupNodeClosingIndex(array $expression)
    {
        $parenthesis = 1;
        $index = 0;

        while ($parenthesis > 0) {
            $index++;
            if ($index > count($expression)) {
                $this->addError('Parenthesis not correctly closed.', self::ERROR_CODE_CLOSING_PARENTHESIS_NOT_FOUND);
            }

            if ('(' === $expression[$index]) {
                $parenthesis++;
            } elseif (')' === $expression[$index]) {
                $parenthesis--;
            }
        }

        return $index;
    }
880056
protected function convert(/*# string */ $pattern)/*# : array */
    {
        // regex
        $groupname   = "\s*([a-zA-Z][a-zA-Z0-9_]*)\s*";
        $grouptype   = ":\s*([^{}]*(?:\{(?-1)\}[^{}]*)*)";
        $placeholder = sprintf("\{%s(?:%s)?\}", $groupname, $grouptype);
        $segmenttype = "[^/]++";

        // count placeholders
        $map = $m = [];
        if (preg_match_all('~'. $placeholder .'~x', $pattern, $m)) {
            $map = $m[1];
        }

        // full regex
        $result = preg_replace([
                '~' . $placeholder . '(*SKIP)(*FAIL) | \[~x',
                '~' . $placeholder . '(*SKIP)(*FAIL) | \]~x',
                '~\{' . $groupname . '\}~x',
                '~' . $placeholder . '~x',
            ], [
                '(?:',  // replace '['
                ')?',   // replace ']'
                '{\\1:' . $segmenttype . '}',   // add segementtype
                '(\\2)'                         // group it
            ], strtr('/' . trim($pattern, '/'), $this->shortcuts)
        );
        return [ $result, $map ];
    }
968249
public Map<String, String> getCellValuesAsMap(String regex, int groupIdx,
            List<ReplacePattern> replaces) {
        Map<String, String> map = new TreeMap<String, String>();

        Pattern pattern = Pattern.compile(regex);
        for (Entry<String, String> entry : getData().entrySet()) {
            Matcher matcher = pattern.matcher(entry.getKey());

            if (matcher.matches()) {
                String value = value(entry.getValue(), replaces);
                map.put(matcher.group(groupIdx), value);
            }
        }
        return map;
    }
974775
private function getMatchingData(array $params, $regex)
    {
        foreach ($params as $data) {
            if (preg_match($regex, $data)) {
                return $data;
            }
        }

        return '';
    }
1000175
private function extractClass($regEx, $classContent)
    {
        preg_match($regEx, $classContent, $matches);
        if (isset($matches[1]) && class_exists($matches[1])) {
            return $matches[1];
        }

        return;
    }
610782
public function matches(string $regex): bool
    {
        if (\func_num_args() !== 1) {
            throw new LogicException('Offset is no longer supported');
        }

        return RegExp::of($regex)->matches($this);
    }