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

Popular posts from this blog

android - Inheriting from Theme.AppCompat* -

broadcastreceiver - android BOOT_COMPLETED not received if not activity intent-filter -

basic authentication with http post params android -