update 2023-06-22 07:54:54
This commit is contained in:
parent
305738aaf7
commit
a1c3b7aacb
@ -177,12 +177,11 @@ final class DailyScripture
|
|||||||
*/
|
*/
|
||||||
private function extract(string $reference): ?string
|
private function extract(string $reference): ?string
|
||||||
{
|
{
|
||||||
// Use regex to match everything before the chapter:verse part
|
// Use regex to match and remove chapter:verse and their variations (if they exist) from the end of the string
|
||||||
preg_match('/^(.*)\s(\d+:\d+|\d+)?$/', $reference, $matches);
|
$bookName = preg_replace('/\s+\d+(:(\d+([,-]\d+)*)?\s*)*$/', '', $reference);
|
||||||
$bookName = $matches[1] ?? '';
|
|
||||||
|
|
||||||
// Check if the book name is a number
|
// If there's no match or the remaining string is empty or numeric, return null
|
||||||
if (is_numeric($bookName) || trim($bookName) === '')
|
if (is_numeric($bookName) || trim($bookName) === '')
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -151,12 +151,11 @@
|
|||||||
*/
|
*/
|
||||||
private function extract(string $reference): ?string
|
private function extract(string $reference): ?string
|
||||||
{
|
{
|
||||||
// Use regex to match everything before the chapter:verse part
|
// Use regex to match and remove chapter:verse and their variations (if they exist) from the end of the string
|
||||||
preg_match('/^(.*)\s(\d+:\d+|\d+)?$/', $reference, $matches);
|
$bookName = preg_replace('/\s+\d+(:(\d+([,-]\d+)*)?\s*)*$/', '', $reference);
|
||||||
$bookName = $matches[1] ?? '';
|
|
||||||
|
|
||||||
// Check if the book name is a number
|
// If there's no match or the remaining string is empty or numeric, return null
|
||||||
if (is_numeric($bookName) || trim($bookName) === '')
|
if (is_numeric($bookName) || trim($bookName) === '')
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user