Check regex against input

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

@return callable
540268
public static function ruleRegex($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);
        };
    }
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);
        };
    }
561665
static function regx($regx, $input)
    {
        $n = preg_match($regx, $input, $match);
        if ($n === 0)
        {
            return false;
        }
        else
        {
            return $match[0];
        }
    }
916458
public function addValidator($slug,$regex){
		$this->regex=null;
		$this->validators[(string)$slug]=(string)$regex;
		return $this;
	}
936701
private function findDelimiter($regex)
    {
        static $choices = ['/', '|', '#', '~', '@'];
        foreach ($choices as $choice) {
            if (strpos($regex, $choice) === false) {
                return $choice;
            }
        }

        throw new \InvalidArgumentException(sprintf('Unable to determine delimiter for regex %s', $regex));
    }
974775
private function getMatchingData(array $params, $regex)
    {
        foreach ($params as $data) {
            if (preg_match($regex, $data)) {
                return $data;
            }
        }

        return '';
    }
23150
public function split( $regex, $limit = - 1 ) {
		$parts = preg_split( $regex, $this->value, $limit );
		for ( $i = 0, $l = count( $parts ); $i < $l; $i ++ ) {
			$parts[ $i ] = new GString( $parts[ $i ] );
		}

		return $parts;
	}
958422
public function responseNotMatches($regex)
    {
        $actual = $this->session->getPage()->getContent();
        $message = sprintf('The pattern %s was found in the HTML response of the page, but it should not.', $regex);

        $this->assert(!preg_match($regex, $actual), $message);
    }
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;
    }
849245
private function regex_search_array($array, $regex) {
		$return = array();
		foreach ($array as $key => $item) {
	 		if(is_array($item)) {
	 			$tmp = $this->regex_search_array($item, $regex);
	 			if($tmp)
	 				$return[$key] = $tmp;
	 		} elseif(!is_object($item)) {
	 			//if (preg_match("/^.*".$regex.".*$/", $this->stripAccents($item))) {
	 			if (preg_match("/".$regex."/i", $this->stripAccents($item))) {
	                $return[$key] = $item;
	           	}
	 		}
		}
	 	
	    return $return;
	}
659249
public Map<String, String> getValByRegex(String regex) {
    Pattern p = Pattern.compile(regex);

    Map<String, String> result = new HashMap<String, String>();
    Matcher m;

    for (Map.Entry<Object, Object> item: getProps().entrySet()) {
      if (item.getKey() instanceof String &&
            item.getValue() instanceof String) {
        m = p.matcher((String) item.getKey());
        if (m.find()) { // match
          result.put((String) item.getKey(), (String) item.getValue());
        }
      }
    }
    return result;
  }
795664
public function rule_regex($a)
    {
        $opt = array();
        $rule = $this->pullRule();
        if ($rule[0] != '/') {
            $rule = '/^'.$rule.'*$/';
        }
        $opt['regexp'] = $rule;

        if (!filter_var($a, FILTER_VALIDATE_REGEXP, ['options' => $opt])) {
            return $this->fail('does not match the pattern');
        }
    }
536549
private function sanitizeRequirement(string $key, string $regex): string
    {
        if ('' !== $regex && '^' === $regex[0]) {
            $regex = substr($regex, 1); // returns false for a single character
        }
        if ('$' === substr($regex, -1)) {
            $regex = substr($regex, 0, -1);
        }
        if ('' === $regex) {
            throw new InvalidArgumentException(sprintf('Routing requirement for "%s" cannot be empty.', $key));
        }

        return $regex;
    }
1035275
public function rule($key, $regex){
		if(!array_key_exists($key, $this->rules))
			$this->rules[$key] = $regex;
	}
1273116
protected function matchUserAgent($regex)
    {
        // only match if useragent begins with given regex or there is no letter before it
        $regex = '/(?:^|[^A-Z0-9\-_]|[^A-Z0-9\-]_|sprd-)(?:' . str_replace('/', '\/', $regex) . ')/i';

        if (preg_match($regex, $this->userAgent, $matches)) {
            return $matches;
        }

        return false;
    }
554127
public function addPatternMatcher(string $alias, string $regex) : self
    {
        $pattern = '/{(.+?):' . $alias . '}/';
        $regex   = '{$1:' . $regex . '}';

        $this->patternMatchers[$pattern] = $regex;

        return $this;
    }
882689
public function whereRegex($expr, $regex, $flags = '')
    {
        $key = $expr;
        $this->_conditions[] = $expr . ' REGEXP ' . (strpos($flags, 'i') !== false ? '' : 'BINARY ') . ':' . $key;
        $this->_bind[$key] = $regex;

        return $this;
    }