PHP Regex for mixed quantities of consecutive characters
Posted on 2010-11-16
I want to match varying quantities of consecutive characters in a string.
For example, in $string I want to replace with nothing (i.e. ""):
any number of instances (consecutive or not) of !@#
and replace instances of 2 or more consecutive -
and replace instances of 3 or more consecutive +
$string='d+++og! + ca#t@ - how about the m--ule';
I'd like to do something like:
to get "dog + cat - how about the mule"
Every variant of moving/removing the parentheses and brackets that I've tried replaces either all instances of - and + including where they only occur once, or replaces no instances at all.
Thank you in advance.