I have the following string examples:
$text = 'Hello world. '; // true
$text = 'Hello world? '; // true
$text = 'Hello world! '; // true
$text = 'Hello world. '; // true
$text = 'Hello world.'; // true
$text = 'Hello world '; // false
$text = 'Hello world'; // false
$text = 'Hello world-'; // false
If string ends with .
or ?
or !
, then return true, otherwise, return false.
What's the best approach to this?