How to replace all non-alphabetic characters with UTF-8 support in PHP
UPDATE: As for Unicode, RegExp will look like this [^\p{L}\s]+
(without replacing spaces)
It will replace all non-alpha characters with UTF8 support.
\P{L}+
- matches any non-letter symbols\p{P}+
- removes punctuation only
Here are some reference docs that can be helpful:
- Tutorial on RegExp UTF8
- Unicode character properties
Use the Unicode character properties:
$str = preg_replace('/\P{L}+/u', '', $str);