I have the following string:
John 1:9
and the following php code:
$parts = preg_split('/[^a-z]/i', $a,2);
var_dump($parts);
It returns the following result (as i expect)
array (size=2)
0 => string 'John' (length=4)
1 => string '1:9' (length=3)
However, i might want the book "1 John 1:9" and it doesn't work to detect "1 John". How do i need to change the regex code to accept numbers 1-4 and a space before the book name?
preg_split('/([1-4])?\s?[a-zA-Z]', $a,2);should sort you out :) explaining: "It may have numbers from 1-to-4, it may have a space, and it has certainly letters from a-to-z, including capitals"