我试图从字符串中去除所有字符,除了:
I'm trying to strip all characters from a string except:
$)_)U+0080和U+FFFF之间的Unicode字符$)_)U+0080 and U+FFFF我通过这样做获得了前三个条件:
I've got the first three conditions by doing this:
preg_replace('/[^a-zA-Zd$_]+/', '', $foo);
如何匹配第四个条件?我查看了使用 X 但有必须比列出 65000 多个字符更好.
How do I go about matching the fourth condition? I looked at using X but there has to be a better way than listing out 65000+ characters.
您可以使用:
$foo = preg_replace('/[^w$x{0080}-x{FFFF}]+/u', '', $foo);
w - 相当于 [a-zA-Z0-9_]x{0080}-x{FFFF} 匹配代码点U+0080和U+FFFF`<之间的字符/li>/u 用于正则表达式中的 unicode 支持
w - is equivalent of [a-zA-Z0-9_]x{0080}-x{FFFF} to match characters between code points U+0080andU+FFFF`/u for unicode support in regex这篇关于一系列 unicode 点 PHP 的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
MySQLi准备好的语句&foreach 循环MySQLi prepared statement amp; foreach loop(MySQLi准备好的语句amp;foreach 循环)
mysqli_insert_id() 是从整个服务器还是从同一用户获Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是从整个服务器还是从同一用户获取记录?)
PHP MySQLi 无法识别登录信息PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 无法识别登录信息)
mysqli_select_db() 需要 2 个参数mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 个参数)
Php mysql pdo 查询:用查询结果填充变量Php mysql pdo query: fill up variable with query result(Php mysql pdo 查询:用查询结果填充变量)
MySQLI 28000/1045 用户“root"@“localhost"的访问MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用户“root@“localhost的访问被拒绝)