How to check if a string ends with punctuation in PHP

1 Answer

0 votes
$s = "PHP Programming.";

if (preg_match("/[.!?,;:]$/", $s))
    echo "yes";
else
    echo "no";

/*
run:

yes

*/

 



answered Nov 9, 2018 by avibootz
...