From 132cf3c9587cd1022332b577c25864bc045b69c8 Mon Sep 17 00:00:00 2001 From: Steffen Lange Date: Wed, 5 Nov 2025 10:32:21 +0100 Subject: [PATCH] Add option to use last regex match --- PatchBase.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PatchBase.php b/PatchBase.php index 2fbfdbd..931df2f 100644 --- a/PatchBase.php +++ b/PatchBase.php @@ -81,8 +81,8 @@ abstract class PatchBase { } return false; } - protected function parse(string $re) : bool { - if ($str = $this->regex_str($re)) { + protected function parse(string $re, bool $last = false) : bool { + if ($str = $this->regex_str($re, $last)) { $this->patch->setVersion($str, true); return true; } @@ -156,10 +156,10 @@ abstract class PatchBase { // TODO - add option: $m = array_reverse($m); return $m; } - private function regex_str(string $pattern) { + private function regex_str(string $pattern, bool $last) { $m = $this->regex($pattern); if ($m) - return $m[0]; + return $last ? end($m) : $m[0]; return false; } }