I have read many posts on SO about preg_matching Bible verses but none of them seems to meet my requirement. I am trying to match the following verses with dot all in one preg_match and retrieve the book name the chapter and the verse.
Hebrews 11.6
2 Chronicles 10.16
Romans 13.13
2 Kings 5.10
3 John 1.5
The verses above should respectfully output
I did
if (preg_match('/[ ]{0,}([0-9]{1}[ ]{0,}[a-zA-ZàâäæáãåāèéêëęėēîïīįíìôōøõóòöœùûüūúÿçćčńñÀÂÄÆÁÃÅĀÈÉÊËĘĖĒÎÏĪĮÍÌÔŌØÕÓÒÖŒÙÛÜŪÚŸÇĆČŃÑ]*)[ ]{0,}([0-9]{1,3})[ ]{0,}:[ ]{0,}([0-9]{1,3})[ ]{0,}/', $bible_passage, $ourmatches))
{
$book = $ourmatches[1];
$chapter = $ourmatches[2];
$verse = $ourmatches[3];
echo "Book $book chapter $chapter verse $verse ";
}
This is able to match those verses but not able to retrieve each book separately with the verse. I want to get the following result
Book Hebrews Chapter 11 verse 6
Book 2 Chronicles Chapter 10 verse 16
Book Romans Chapter 13 verse 13
Book 2 Kings Chapter 5 verse 10
Book 3 John Chapter 1 verse 5
For Hebrews 11.6 what I get is Book 1 Chapter 1 verse 6 instead of Book Hebrews Chapter 1 verse 6
Please how to fix this?