I want to match a number placed at the end of a string or maybe the middle.
The example would be:
"chapter some word 12 or IV" or "chapter some word 12 or IV some word"
the number what I want to extract is "12" or IV from the string.
I have tried to look around with ?:\w*
or ?=\w*
but it does not work.
My regex:
if (preg_match('/ch\w*\s*\K(?|(?=((?<=|\s)\d+(?:\.\d+)?))|(?=([ivx]+(?![a-z]))))/i', $string, $matches)){
print_r($matches);
}
Am I missing something with the regex? Any pointers in the right direction would be appreciated.