phmLabs/Smoke · RegExExistsRule.php
php logo
public function init(array $regExs)
    {
        $regExArray = array();

        foreach ($regExs as $regEx) {
            if (array_key_exists('regex', $regEx)) {
                $isRegex = $regEx['isRegex'] == 'on';
                $regExArray[] = ['pattern' => $regEx['regex'], 'isRegEx' => $isRegex];
            } else {
                $regExArray[] = $regEx;
            }
        }

        $this->regExs = $regExArray;
    }
Similar code snippets
1.
marcmascarell/formality · Parser.php
Match rating: 67.26% · See similar code snippets
php logo
protected function matchesRegex($name, $types)
    {
        foreach ($types as $type => $data) {
            if (! isset($data['regex'])) {
                continue;
            }

            foreach ($data['regex'] as $regex) {
                if (preg_match($regex, $name, $matches)) {
                    $this->setTypeReason($name, "matched regex '{$regex}'");

                    return $type;
                }
            }
        }

        return false;
    }
2.
M6Web/Firewall · IPMask.php
Match rating: 66.72% · See similar code snippets
php logo
public static function getMatchRegex()
    {
        $pRegex     = IPRange::getMatchRegex();
        $regex      = substr($pRegex, 2, ( strlen($pRegex) - 4 ));
        $separator  = static::$separatorRegex;
        $maskRegex  = static::getMaskRegex();

        return  sprintf("/^%s%s%s$/", $regex, $separator, $maskRegex);
    }
3.
Rehyved/php-utilities · RegexValidator.php
Match rating: 64.47% · See similar code snippets
php logo
public function validate($value, $regex, string $valueName)
    {
        if($value === null){
            return null;
        }

        if(!is_string($value)){
            throw new \InvalidArgumentException("The value checked on the regex annotation for regex '$regex' is not a valid string. (name of value '$valueName')");
        }

        if(!is_string($regex)){
            throw new \InvalidArgumentException("The regex on the regex annotation is not a string and thus no regex. (name of value '$valueName')");
        }

        if(preg_match($regex, $value) < 1){
            return new RegexValidationError($valueName, $value, $regex);
        }

        return null;
    }
4.
JamesMcAvoy/PsrRouter · Route.php
Match rating: 63.97% · See similar code snippets
php logo
private function preg(String $reg) : String {

		if($reg['0'] == $reg[strlen($reg)-1] && ($reg['0'] == '/' || $reg['0'] == '#'))
			$reg = trim($reg, $reg['0']);
		if($reg['0'] != '(')
			$reg = '('.$reg;
		if($reg[strlen($reg)-1] != ')')
			$reg .= ')';
		return $reg;

	}
5.
oliwierptak/Everon1 · Regex.php
Match rating: 63.88% · See similar code snippets
php logo
protected function regexValidate($name, $regex)
    {
        $match = (@preg_match($regex, null));
        if ($match === false) {
            throw new Exception\Helper('Invalid regex for: "%s"', $name);
        }
    }
6.
dereuromark/media-embed · MediaEmbed.php
Match rating: 63.84% · See similar code snippets
php logo
protected function _matchUrl($url, array $regexRules) {
		foreach ($regexRules as $regexRule) {
			if (preg_match('~' . $regexRule . '~imu', $url, $match)) {
				return $match;
			}
		}
		return [];
	}
7.
samurai-fw/samurai · GlobExpression.php
Match rating: 63.09% · See similar code snippets
php logo
public function getRegexPattern()
    {
        $regex = preg_quote($this->value, '/');
        $regex = substr($regex, -1) !== '*' ? $regex . '$' : $regex;
        $regex = preg_replace('/\\\\\\*/', '.*?', $regex);
        return "/^{$regex}/";
    }
8.
AymDev/PPRR · PPRR.php
Match rating: 62.89% · See similar code snippets
php logo
private static function buildRegex(string $expression, bool $is_prefix = false) : string
    {
        $regex  = self::REGEX_DELIMITER . '^';
        $regex .= preg_replace(array_keys(self::$datatypes), self::$datatypes, $expression);
        $regex .= $is_prefix ? '(.*)' : '';
        $regex .= '$' . self::REGEX_DELIMITER;
        return $regex;
    }
9.
symbiote/silverstripe-addressable · Addressable.php
Match rating: 62.79% · See similar code snippets
php logo
private function getPostcodeRegex()
    {
        // Get postcode regex from extending object. (ie. Page, DataObject)
        $regex = $this->owner->config()->postcode_regex;
        if ($regex) {
            return $regex;
        }

        // Get postcode  regex global. If there are no specific rules on a Page/DataObject
        // fallback to what is configured on this extension
        $regex = Config::inst()->get(__CLASS__, 'postcode_regex');
        if ($regex) {
            return $regex;
        }

        return '';
    }
10.
manaphp/framework · Query.php
Match rating: 62.43% · See similar code snippets
php logo
public function whereRegex($field, $regex, $flags = '')
    {
        $this->_filters[] = [$field => ['$regex' => $regex, '$options' => $flags]];

        return $this;
    }