My regular expression works well when there is a space after the dot.
$str = 'Fry me a Beaver. Fry me a Beaver! Fry me a Beaver? Fry me Beaver no. 4?! Fry me many Beavers... End';
$sentences = preg_split('/(?<=[.?!])\s+(?=[a-z])/i', $str);
But I need it to work as well, when there is a \n
after the dot.
$str = 'Fry me a Beaver. Fry me a Beaver!\nFry me a Beaver? Fry me Beaver no. 4?! Fry me many Beavers... End';
I can't add a \n
to the regular.