@param string       $value
@param integer|null $amount
@param string       $regex

@return bool
979899
private static function hasStringSubset($value, $amount, $regex)
    {
        \settype($value, 'string');

        $minMatches = 1;
        if (!empty($amount)) {
            $minMatches = $amount;
        }

        $value  = \preg_replace('/\s+/', '', $value);
        $length = \strlen($value);

        $counter = 0;
        for ($i = 0; $i < $length; $i++) {
            if (\preg_match($regex, $value[$i]) > 0) {
                $counter++;
            }

            if ($counter === $minMatches) {
                return true;
            }
        }

        return false;
    }
987926
protected function sanitize($value, $key = null, $regex = '/\s+/', $replace = ' ')
    {
        $value = $this->checkValue($value, $key);

        return $value == null ? null : utf8_decode(trim(preg_replace($regex, $replace, $value)));
    }
754108
public static PactDslJsonRootValue stringMatcher(String regex, String value) {
    if (!value.matches(regex)) {
      throw new InvalidMatcherException(EXAMPLE + value + "\" does not match regular expression \"" +
        regex + "\"");
    }
    PactDslJsonRootValue rootValue = new PactDslJsonRootValue();
    rootValue.setValue(value);
    rootValue.setMatcher(new RegexMatcher(regex, value));
    return rootValue;
  }
1050595
public static function validate($value)
    {
        if (!is_numeric($value)) {
            return false;
        }

        $stringLength = strlen($value);

        if ($stringLength !== 9 && $stringLength !== 8) {
            return false;
        }

        $sum = 0;
        $multiplier = $stringLength;
        for ($counter = 0; $counter < $stringLength; $counter++, $multiplier--) {
            if ($multiplier == 1) {
                $multiplier = -1;
            }

            $sum += substr($value, $counter, 1) * $multiplier;
        }

        return $sum % 11 === 0;
    }
378526
protected static function _check($check, $regex)
	{
		if (is_string($regex) && preg_match($regex, $check))
		{
			return true;
		}
		return false;
	}
924880
public function validate(
        &$value,
        \sndsgd\form\Validator $validator = null
    ): bool
    {
        $url = parse_url($value);
        if (!is_array($url)) {
            return false;
        }

        foreach ($this->requiredParts as $part) {
            if (!isset($url[$part])) {
                return false;
            }
        }

        return true;
    }
588708
protected function vaidateValue($value, $element)
    {
        if (isset($this->patterns[$this->getRegexp()])) {
            return (bool) preg_match($this->patterns[$this->getRegexp()], $value);
        } elseif ($this->getRegexp()) {
            return (bool) preg_match('/^' . $this->getRegexp() . '$/' . $this->getModifiers(), $value);
        } else {
            return false;
        }
    }
1159868
private function match($value, $regStr) {
        return $this -> type($value, 'string', 'number') && ($this -> equal($value, $regStr) || (preg_match(strval($regStr), strval($value)) > 0));
    }
1160722
public static function isSizeValue($value, $separator = ' x ')
    {
        /*
         * Not a string?
         * Nothing to do
         */
        if (!is_string($value)) {
            return false;
        }

        $pattern = self::getSizePattern($separator);

        return (bool)preg_match($pattern, $value);
    }
552939
public function setAmount($value)
    {
        if ($value === null || $value === '') {
            $this->_amount = null;
        } else {
            if (!is_scalar($value)) {
                if (!is_object($value) || !method_exists($value, '__toString')) {
                    throw new InvalidPropertyValueTypeException(
                        'Invalid amount value type', 0, 'amount.value', $value
                    );
                }
                $value = (string)$value;
            }
            if (!is_numeric($value) || $value < 0.0) {
                throw new InvalidPropertyValueException(
                    'Invalid amount value "' . $value . '"', 0, 'amount.value', $value
                );
            } elseif ($value < 0.01) {
                $this->_amount = null;
            } else {
                $this->_amount = number_format($value, 2, '.', '');
            }
        }
    }
1203077
public function checkWords($value, $count)
    {
        if (!Type::isStringLike($value)) {
            return $count == 0;
        }

        return count(preg_split('~[^\p{L}\p{N}\']+~u', $value, -1, PREG_SPLIT_NO_EMPTY)) == $count;
    }
795106
public function checkDigits($value, $count)
    {

        if (is_numeric($value)) {
            $value = "$value";
        }

        if (!Type::isStringLike($value)) {
            return false;
        }

        return ! preg_match('/[^0-9]/', "$value")
            && strlen("$value") == $count;
    }
902599
function setsOf(value, amount = 4, divider = ' ') {
  const num = parseInt(amount, 10);

  if (Number.isNaN(num) || typeof value !== 'string') {
    return '';
  }

  const regex = new RegExp('.{1,' + amount + '}', 'g');
  return value.match(regex).join(divider);
}
1126325
protected static function _check($check, $regex)
    {
        return is_string($regex) && is_scalar($check) && preg_match($regex, $check);
    }
974119
private function matchValue($value, $pattern)
    {
        // basic check
        if ($value == $pattern) {
            return true;
        }

        // simple check in case of optional param
        if ($pattern == '?') {
            return true;
        }

        // simple match in case pattern is just "*"
        if ($pattern == '*' && $value != '') {
            return true;
        }

        // more complex match in case when wildcard is part of a larger match
        $pattern = str_replace('*', '(.+)', $pattern);

        // regex match
        if (strpos($pattern, '(') !== false || strpos($pattern, '[') !== false || strpos($pattern, '\\') !== false) {
            return preg_match('#^' . $pattern . '$#', $value);
        }

        return false;
    }
561665
static function regx($regx, $input)
    {
        $n = preg_match($regx, $input, $match);
        if ($n === 0)
        {
            return false;
        }
        else
        {
            return $match[0];
        }
    }
72306
private static boolean matchRuleRegex(String regex, String value) {

        if (value == null) {
            value = "";
        }

        if (regex == null) {
            return true;
        }
        if ((regex.length() > 0) && (regex.charAt(0) == '!')) {
            return !value.matches(regex.substring(1));
        } else {
            return value.matches(regex);
        }
    }