我正在使用PHP解析一个大文本文件,有些行看起来像"äåòñêèåïåñíè",或"ääò",或者像这样的"åãîðëåò".有没有办法检查字符串中是否有超过三个这样的字符?
谢谢.
你可以尝试:
if (preg_match("/(?:.*?[\x80-\xFF]){3,}/", $string)) {
// report excess high-bit ascii
}
(?: ; create a non-capture group
.*? ; match any number of characters, without being greedy.
[\x80-\xFF] ; match a single high-bit character
) ; end the group
{3,} ; match the group 3 or more times
Run Code Online (Sandbox Code Playgroud)
您的问题标题躲避删除:
$out = preg_replace('/[\x80-\xFF]/', '', $input);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8025 次 |
| 最近记录: |