Converts the string of regexes

@see self::process_form_data()
@param $regexes string of regexes
@return array of form fields and their values
488388
protected function prepare_form_data($regexes) {

        $regexes = json_decode($regexes);

        $form = array();

        $i = 0;

        foreach ($regexes as $value => $regex) {
            $expressionname  = 'expression'.$i;
            $valuename = 'value'.$i;

            $form[$expressionname] = $regex;
            $form[$valuename] = $value;
            $i++;
        }

        return $form;
    }
363029
protected function getRegexes()
    {
        if (empty($this->regexList)) {
            $cacheKey = 'DeviceDetector-'.DeviceDetector::VERSION.'regexes-'.$this->getName();
            $cacheKey = preg_replace('/([^a-z0-9_-]+)/i', '', $cacheKey);
            $this->regexList = $this->getCache()->fetch($cacheKey);
            if (empty($this->regexList)) {
                $this->regexList = $this->getYamlParser()->parseFile(
                    $this->getRegexesDirectory().DIRECTORY_SEPARATOR.$this->fixtureFile
                );
                $this->getCache()->save($cacheKey, $this->regexList);
            }
        }
        return $this->regexList;
    }
1250679
public function _parseParams(array $matches)
    {
        $params = array();
        foreach ($matches as $k => $v) {
            if (is_numeric($k)) {
                if ($k === 0) {
                    continue;
                }
                $params[] = $v;
            } else {
                $params[$k] = $v;
            }
        }
        return new Set($params);
    }
1104302
protected function _setRegexps($regexps)
    {
        if (!is_array($regexps)) {
            Zend_Cache::throwException('regexps option must be an array !');
        }
        foreach ($regexps as $regexp=>$conf) {
            if (!is_array($conf)) {
                Zend_Cache::throwException('regexps option must be an array of arrays !');
            }
            $validKeys = array_keys($this->_specificOptions['default_options']);
            foreach ($conf as $key=>$value) {
                if (!is_string($key)) {
                    Zend_Cache::throwException("unknown option [$key] !");
                }
                $key = strtolower($key);
                if (!in_array($key, $validKeys)) {
                    unset($regexps[$regexp][$key]);
                }
            }
        }
        $this->setOption('regexps', $regexps);
    }
880002
protected function parseFields($fields)
    {
        $fieldsArray = explode(',', $fields);
        $text = '$this'."\n";

        foreach ($fieldsArray as $field) {
            $text .= $this->prepareAdd($field, end($fieldsArray) == $field);
        }

        return $text.';';
    }
81499
public function parse( $rules ) {
		if ( is_array( $rules ) ) {
			return $this->parse_array_rules( $rules );
		}

		return $this->parse_string_rules( $rules );
	}
334282
protected function replaceConfigExpression($matches) {
		$property = $matches[1];
		//check key existence
		if (!array_key_exists($property, $this->config))
			return '';
		//convert to string, if possible
		if (($str = $this->toString($this->config[$property])) === false)
			return '';
		return $str;
	}
34591
protected static function replaceOptionalSegments($regex)
    {
        preg_match(chr(1) . '\(/([a-z][a-zA-Z0-9_,]*)\)' . chr(1), $regex, $matches);

        if (!$matches) {
            return $regex;
        }

        $list = explode(',', $matches[1]);
        $head = '';

        if (substr($regex, 0, 2) === '(/') {
            $name = array_shift($list);
            $head = "/(\{{$name}\})?";
        }

        $tail = '';

        foreach ($list as $name) {
            $head .= "(/({$name})";
            $tail .= ')?';
        }

        $repl = $head . $tail;

        return str_replace($matches[0], $repl, $regex);
    }
1264894
public function regexp($regexp)
    {
        $results = [];
        foreach ($this->columns as $name => $column) {
            $column = trim($column);
            if (preg_match($regexp, $name)) {
                $results[] = $name;
            }
        }

        return new Result($results, $this->columns);
    }
281225
public function formToArray($form)
    {
        $result = [];
        if (preg_match_all('/<input[^>]*>/sm', $form, $inputs) !== false) {
            foreach ($inputs[0] as $input) {
                if (preg_match('/name=["\']([^"\']*)["\']\s+value=["\']([^"\']*)["\']/', $input, $match) !== false) {
                    if (count($match) === 3) {
                        $result[$match[1]] = $match[2];
                    }
                }
            }
        }

        return $result;
    }
1354079
protected static function in_array_matches_regex($test, $patterns)
    {
        foreach($patterns as $val) {
            if(@preg_match($val, null) === false) {
                if( strcasecmp($val, $test) === 0 ) {
                    return true;
                }
            } else {
                if( preg_match($val, $test) === 1 ) {
                    return true;
                }
            }
        }
        return false;
    }
591992
protected function match(array $regexes, $string)
    {
        $pattern = '#(?<!like )('.join('|', $regexes).')#i';

        if (preg_match($pattern, $string, $matches)) {
            return $matches;
        }

        return false;
    }
920918
protected function parseStringRule($rules)
    {
        $parameters = [];

        // The format for specifying validation rules and parameters follows an
        // easy {rule}:{parameters} formatting convention. For instance the
        // rule "Max:3" states that the value may only be three letters.
        if (strpos($rules, ':') !== false) {
            list($rules, $parameter) = explode(':', $rules, 2);

            $parameters = $this->parseParameters($rules, $parameter);
        }

        return [studly_case(trim($rules)), $parameters];
    }
1183160
protected function normalizeShortOptions(array $matches) {
        $newMatches = [];

        foreach ($matches as $match) {
            if ( ! str_starts_with($match, '--')
                && str_starts_with($match, '-')
                && strlen($match) > 2
            ) {
                // convert options like -abc to -a -b -c
                foreach (str_split(substr($match, 1)) as $match) {
                    $newMatches[] = "-$match";
                }
            } else {
                $newMatches[] = $match;
            }
        }

        return $newMatches;
    }
198266
public static function values(array $tokens) {
        $values = explode(',', self::removeBrackets(self::removeSpacesBetweenComma(end($tokens['VALUES'])['base_expr'])));

        return array_map(function($value) {
            return Value::create($value);
        }, $values);
    }
1055704
public function convertToRegex($matches)
    {
        $key = str_replace(':', '', $matches[0]);
        if (array_key_exists($key, $this->conditions)) {
            return '(' . $this->conditions[$key] . ')';
        } else {
            return '([a-zA-Z0-9_\-\.]+)';
        }
    }
130632
private function extractParams($matches)
    {
        return array_map(
            function ($match) {
                $args = explode('/', trim($match, '/'));

                return isset($args[0]) ? $args[0] : null;
            },
            array_slice(
                $matches[0],
                1
            )
        );
    }