小编jam*_*mes的帖子

替换非utf8字符

我想允许所有 utf8 字符,但想用空格或 - 替换非 utf8

这是字符串

Punjab me 1Train k niche 100 Sardar aa gaye..

99 Mar gaye...

1 Bach gaya
Run Code Online (Sandbox Code Playgroud)

无论我做什么,它都不会在火车后插入

它在火车上的修剪

我已经尝试过这两个链接

我想要完整的 utf8 范围插入 mysql 并用空格或 - 替换非 utf8

$string = preg_replace('/[^(\x20-\x7F)]*/','', $string);
Run Code Online (Sandbox Code Playgroud)

适用于上述情况,但当我使用印地文/中文时,它也会替换它。所以我不能使用上面的代码

php regex mysql utf-8

5
推荐指数
1
解决办法
2608
查看次数

标签 统计

mysql ×1

php ×1

regex ×1

utf-8 ×1