Dim*_*tri 2 php regex preg-replace non-ascii-characters
我想更改我的字符串中的所有特殊字符,但我想保留所有重音字符.有可能preg_replace()吗?
我目前的代码:
preg_replace('/[^A-Za-z0-9\-]/', '', $string);
Run Code Online (Sandbox Code Playgroud)
试试Unicode:
preg_replace('/[^\p{L}0-9\-]/u', '', $string);
Run Code Online (Sandbox Code Playgroud)
\p{L}是一个Unicode属性,匹配任何语言中的所有字母,php.net上的Unicode属性