Check regex against input and returns reveresed result

@param string  $regex  Name of the rule (unique per attribute)

@return callable
185330
public static function ruleRegexInverse($regex)
    {
        $args = func_get_args();
        $regex = join(':', $args);

        /*not in format "/../<modifier>", "#..#<modifier>"  nor "~..~<modifier>" */
        if (!preg_match('/^([\/#~]).+\1[msugex]*$/', $regex)) {
            $regex = '/'. stripslashes($regex). '/';
        }

        return function ($input) use ($regex) {
            return !preg_match($regex, $input);
        };
    }
974775
private function getMatchingData(array $params, $regex)
    {
        foreach ($params as $data) {
            if (preg_match($regex, $data)) {
                return $data;
            }
        }

        return '';
    }
984949
protected static function replaceWildcards($regex)
    {
        preg_match_all(chr(1) . '\(\\*([a-z][a-zA-Z0-9]*)\)' . chr(1), $regex, $matches, PREG_SET_ORDER);

        foreach ($matches as $match) {
            $name = $match[1];

            $regex = str_replace("(*{$name})", "(?P<{$name}>.*)", $regex);
        }

        return $regex;
    }
1361734
public function match($input)
    {
        // Match the input with the regex pattern, storing any match found into the $matches variable,
        // along with the index of the string at which it was matched.
        $result = preg_match($this->pattern, $input, $matches, PREG_OFFSET_CAPTURE);

        // preg_match returns false if an error occured
        if ($result === false)
            throw new \Exception(preg_last_error());

        // 0 means no match was found
        if ($result === 0)
            return null;

        return $this->getTokenFromMatch($matches[0]);
    }
685998
protected function scanInput($regex, $type)
    {
        if (!preg_match($regex, $this->line, $matches)) {
            return null;
        }

        $token = $this->takeToken($type, $matches[1]);
        $this->consumeLine();

        return $token;
    }
1136143
public function isMatch(
        $regexPattern,
        array $regexModifierList,
        $string
    ) {
        foreach ($regexModifierList as $regexModifier) {
            $this->validateRegexModifier($regexModifier);
        }

        $result = preg_match('/' . $regexPattern . '/' . implode('', $regexModifierList), $string);

        if ($result === false) {
            throw new RegexErrorException('Regex error');
        }

        if (preg_last_error() !== PREG_NO_ERROR) {
            throw new RegexErrorException(
                sprintf(
                    'Regex error (error: "%s")',
                    $this->errorMap[preg_last_error()]
                )
            );
        }

        return $result === 1 ? true : false;
    }
195558
public function getValidInput($clean = false)
    {
        $input = array_dot($this->all());
        $rules = array_keys($this->rules());

        $keys = collect($rules)->map(function (string $rule) use ($input) {
            // Transform each rule to a regex string while supporting
            // the wildcard (*) character to include sequential arrays too.
            $regex = '/^' . str_replace(['.', '*'], ['\.', '(.*)'], $rule) . '$/';

            // Match the regex string against our input fields
            return preg_grep($regex, array_keys($input));
        });

        // Match the input attributes against the existing rules
        $input = array_only($input, $keys->flatten()->toArray());

        // Reverse dot flattening to match original input
        $expanded = [];

        foreach ($input as $key => $value) {
            array_set($expanded, $key, $value);
        }

        if ($clean) {
            $expanded = $this->sanitizeInput($expanded);
        }

        return $expanded;
    }
1325920
public function match($regex)
    {
        $match = array();
        if($this->isValidRegex($regex) && preg_match($regex, $this->toString(), $match)===1)
        {
            return new ObjectArray($match);
        }
        return null;
    }
717178
private function replaceTokensWithRegexCaptureGroups($regex)
    {
        $tokenRegex = self::TOKEN_REGEX;

        return preg_replace_callback(
            self::PLACEHOLDER_REGEXP,
            array($this, 'replaceTokenWithRegexCaptureGroup'),
            $regex
        );
    }
75228
public function links($regex = null)
    {
        /**
         * @var \DOMElement $node
         */
        $data = [];
        foreach ($this->_document->getQuery()->xpath('descendant::a[@href]', $this->_node) as $node) {
            $href = $this->_document->absolutizeUrl($node->getAttribute('href'));

            if ($regex && !preg_match($regex, $href)) {
                continue;
            }

            $data[$node->getNodePath()] = ['href' => $href, 'text' => $node->textContent];
        }

        return $data;
    }
940255
public static function getLineNumber($file, $regex)
    {
        $i = 0;
        $lineFound = false;
        $handle = @fopen($file, 'r');
        if ($handle) {
            while (($buffer = fgets($handle, 4096)) !== false) {
                $i++;
                if (preg_match($regex, $buffer)) {
                    $lineFound = true;
                    break;
                }
            }
            fclose($handle);
        }
        return $lineFound ? $i : false;
    }
747265
public function grep($pattern)
    {
        $results = array_intersect_key($this->attributes, array_flip(
            RegexGuard::getGuard()->grep($pattern, array_keys($this->attributes))
        ));

        return new static($results);
    }
226138
public function assert(string $key, string $regex): self
    {
        return $this->setRequirement($key, $regex);
    }
877834
private function execute($regex, $data)
    {
        $matches = [];

        preg_match($regex, (string)$data, $matches);

        return $matches;
    }
163038
public function getMethodsByPattern($regex)
    {
    	$methods = array();
        foreach ($this->xmlRoot->method as $method) {
    		if (preg_match("/$regex/", $method['name'])) {
		        $moufRefMethod = new MoufXmlReflectionMethod($this, $method);
		        $methods[] = $moufRefMethod;
    		}
    	}
    	return $methods;
    }
1306536
protected function _validator_regex($input, $value, $regex) {
		if (!is_string($value) && !is_integer($value) && !is_float($value)) return false;
		if (!preg_match($regex, $value)) return false;
		return true;
	}
718602
public static Predicate<String> matchesRegex(final String regex) {
		final Pattern pattern = Pattern.compile(regex);
		return matchesRegex(pattern);
	}