diff --git a/src/Regex/private.php b/src/Regex/private.php index f6e8093..7e5ebea 100644 --- a/src/Regex/private.php +++ b/src/Regex/private.php @@ -17,3 +17,15 @@ function _unprefixed(string $string, string $prefix): string { } return $string; } + +function _errorMessage(string $phpMessage, string $methodName, string $errorPattern): string { + $errorMessage = _unprefixed($phpMessage, "$methodName(): "); + [$pcreMessage, $offset] = \explode(' at offset ', $errorMessage); + $compilationPrefix = 'Compilation failed: '; + if (\str_starts_with($pcreMessage, $compilationPrefix)) { + return _denoted( + \subStr($pcreMessage, \strLen($compilationPrefix)), + $errorPattern, $offset); + } + return $errorMessage; +} diff --git a/src/public.php b/src/public.php index 5f920a3..57d5130 100644 --- a/src/public.php +++ b/src/public.php @@ -1,9 +1,8 @@