I am trying to write a function to clean up user input.
I am not trying to make it perfect. I would rather have a few names and acronyms in lowercase than a full par
This:
$text = "abc. def! ghi? jkl.\n"; print $text; $text = preg_replace("/([.!?]\s*\w)/e", "strtoupper('$1')", $text); print $text; ?> Output: abc. def! ghi? jkl. abc. Def! Ghi? Jkl.
Note that you do not have to escape .!? inside [].