4
0

update 2023-06-22 07:54:54

This commit is contained in:
Robot 2023-06-22 07:54:54 +02:00
parent 305738aaf7
commit a1c3b7aacb
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
2 changed files with 8 additions and 10 deletions

View File

@ -177,12 +177,11 @@ final class DailyScripture
*/
private function extract(string $reference): ?string
{
// Use regex to match everything before the chapter:verse part
preg_match('/^(.*)\s(\d+:\d+|\d+)?$/', $reference, $matches);
$bookName = $matches[1] ?? '';
// Use regex to match and remove chapter:verse and their variations (if they exist) from the end of the string
$bookName = preg_replace('/\s+\d+(:(\d+([,-]\d+)*)?\s*)*$/', '', $reference);
// Check if the book name is a number
if (is_numeric($bookName) || trim($bookName) === '')
// If there's no match or the remaining string is empty or numeric, return null
if (is_numeric($bookName) || trim($bookName) === '')
{
return null;
}

View File

@ -151,12 +151,11 @@
*/
private function extract(string $reference): ?string
{
// Use regex to match everything before the chapter:verse part
preg_match('/^(.*)\s(\d+:\d+|\d+)?$/', $reference, $matches);
$bookName = $matches[1] ?? '';
// Use regex to match and remove chapter:verse and their variations (if they exist) from the end of the string
$bookName = preg_replace('/\s+\d+(:(\d+([,-]\d+)*)?\s*)*$/', '', $reference);
// Check if the book name is a number
if (is_numeric($bookName) || trim($bookName) === '')
// If there's no match or the remaining string is empty or numeric, return null
if (is_numeric($bookName) || trim($bookName) === '')
{
return null;
}