diff --git a/libraries/Util.class.php b/libraries/Util.class.php index 9d3e5c2e569f..80f12f77ed48 100644 --- a/libraries/Util.class.php +++ b/libraries/Util.class.php @@ -4051,12 +4051,12 @@ public static function getFirstOccurringRegularExpression($regex_array, $query) $minimum_first_occurence_index = null; $regex = null; - for ($i = 0; $i < count($regex_array); $i++) { - if (preg_match($regex_array[$i], $query, $matches, PREG_OFFSET_CAPTURE)) { + 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 = $regex_array[$i]; + $regex = $test_regex; $minimum_first_occurence_index = $matches[0][1]; } }