diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 754e9ae3..cc32aa53 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,6 +33,8 @@ jobs: fail-fast: false matrix: php-versions: + - '5.4' + - '5.5' - '5.6' - '7.0' - '7.1' diff --git a/Highlight/RegEx.php b/Highlight/RegEx.php index d61ab033..4fba2036 100644 --- a/Highlight/RegEx.php +++ b/Highlight/RegEx.php @@ -76,13 +76,13 @@ public function exec($str) { $index = null; $results = array(); - preg_match_all($this->source, $str, $results, PREG_SET_ORDER | PREG_OFFSET_CAPTURE, $this->lastIndex); + preg_match($this->source, $str, $results, PREG_OFFSET_CAPTURE, $this->lastIndex); if ($results === null || count($results) === 0) { return null; } - foreach ($results[0] as &$result) { + foreach ($results as &$result) { if ($result[1] !== -1) { // Only save the index if it hasn't been set yet if ($index === null) { @@ -95,7 +95,8 @@ public function exec($str) } } - $results = $results[0]; + unset($result); + $this->lastIndex += mb_strlen($results[0]) + ($index - $this->lastIndex); $matches = new RegExMatch($results);