Tag Archives: regex

Remove repeated adjacent characters from string

Given a string like: “aabbdeeeef” or “bbbbbbb” we want to output: “abdef” and “b” respectively. here are a few ways to do it in Python:

Count words using Regex

Yes, i know, very very easy. But i am leaving this here as reference: $texto = “how to count words in a very simple step”; $contagem = preg_match_all(“/\w+/”, $texto, $blaharray); echo $contagem; // 9 For further reading: Regular Expressions info preg_match() preg_match_all()