PMA\libraries\Util::getFirstOccurringRegularExpression PHP Method

getFirstOccurringRegularExpression() public static method

Get regular expression which occur first inside the given sql query.
public static getFirstOccurringRegularExpression ( array $regex_array, String $query ) : String
$regex_array array Comparing regular expressions.
$query String SQL query to be checked.
return String Matching regular expression.
    public static function getFirstOccurringRegularExpression($regex_array, $query)
    {
        $minimum_first_occurence_index = null;
        $regex = null;
        foreach ($regex_array as $test_regex) {
            if (preg_match($test_regex, $query, $matches, PREG_OFFSET_CAPTURE)) {
                if (is_null($minimum_first_occurence_index) || $matches[0][1] < $minimum_first_occurence_index) {
                    $regex = $test_regex;
                    $minimum_first_occurence_index = $matches[0][1];
                }
            }
        }
        return $regex;
    }
Util