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

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -