I want to rid a text for repeated exclamation marks (!!!), question marks (??) or full stops (....) and replace them with a single instance of themselves. So I need "one preg_replace to rule them all" basically.
I currently have three separate patterns being executed:
preg_replace("/[!]{2,}/","!", $str);
preg_replace("/[?]{2,}/","?", $str);
preg_replace("/[.]{2,}/",".", $str);
Is there a way to replace the found character with a single instance of itself using just one regex pattern?
I need to turn:
Ok!!!
Really????
I guess.....
into:
Ok!
Really?
I guess.
With one regex pattern.