php - Replace repeating characters with exceptions -
how can translate regex: replace char (aka '.') repeating more once , replace 1 of char exception of "ii" , "iii".
$reg = preg_replace('/(.)/1{1,}/','', $string); now must replace vvvvv v or .... . , must not replace criiid (or criid) criiiiiiid crid.
feel free comment if don't understand question.
preg_replace('/([^i])\1+|(i){4,}/', '\1\2', $string) note squeeze everything -- spaces, newlines, etc.
Comments
Post a Comment