您好,我正在向 zend_lucene_search 提供上下文,它可以搜索最多特殊字符的单词,之后就无法搜索了。
例如:
very well to the other job boards � one of the main things that has impressed is the variety of the applications, especially with regards to the background of the candidates" manoj � Head
如果我搜索“boards”,我可以找到它,但如果我在不可读的字符之后搜索一个或任何字符串,我无法搜索它。
如何删除这些内容,我想要获取纯文本。
我在将 .docx/pdf 文件转换为文本时遇到了这些字符。
或者
让我知道如何仅向 zend_search_lucene 提供文本..
请帮忙。
最佳答案
您可以使用以下 preg_replace
函数调用从字符串中删除所有非 ASCII(所谓的特殊)字符:
$replaced = preg_replace('/[^\x00-\x7F]+/', '', $str);
// produces this converted text:
// "very well to the other job boards one of the main things that has impressed
// is the variety of the applications, especially with regards to the background of the
// candidates" manoj Head"
关于php - 如何使用 PHP 删除上下文中不可读的字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10816966/