Input: "abbbcdaa" Output: "abcd"
With the follow regex the out put is abcda
preg_replace('/(.)\\1*/', '$1', "abbbcdaa");
how to get abcd using pre_replace
Input: "abbbcdaa" Output: "abcd"
With the follow regex the out put is abcda
preg_replace('/(.)\\1*/', '$1', "abbbcdaa");
how to get abcd using pre_replace
This should do it:
$string="abbbcdaa";
echo preg_replace('/(.)(?=.*?\1)/','',$string);
The above outputs:
bcda
Alternatively, you can use:
echo count_chars($string,3);
That would also return unique characters abcd
.
Good luck!