Regex - removing symbols in utf8 text

Hello,

How is it possible to remove all symbols (",.-=?<>…) from a text and keep all utf-8 international characters ?

For example:

“wärm test-10 +?= madafak < test”
to
“wärm test10 madafak test”

Thanks for help

You can add unicode ranges using the u modifier.

I tried this:


$input = "wärm test-10 +?= madafak < test";
$output = preg_replace("/[^\\w]/u", ' ', $input);

But it wont really help… it will strip out ä

You need to whitelist the characters you want to keep using the following notation:-

http://www.php.net/manual/en/function.preg-match.php#102214

AFAIK anyway. :slight_smile: