I am trying to replace in a string all non word characters with empty string expect for spaces and the put together all multiple spaces as one single space.
Followin
mb_ereg_replace doesn't use separators. You may or may not also have to specify the encoding before.
mb_ereg_replace
mb_regex_encoding("UTF-8"); //regex could also be \W $cleanedString = mb_ereg_replace('[^\w]', ' ', $name); $cleanedString = mb_ereg_replace('\s+', ' ', $cleanedString);