PHP filter English punctuation marks to filter Chinese punctuation code
Copy Code code as follows:
function Filter_mark ($text) {
if (Trim ($text) = = ') return ';
$text =preg_replace ("/[[:p unct:]\s]/", "", $text);
$text =urlencode ($text);
$text =preg_replace ("/(%7e|%60|%21|%40|%23|%24|%25|%5e|%26|%27|%2a|%28|%29|%2b|%7c|%5c|%3d|\-|_|%5b|%5d|%7d|%7b |%3b|%22|%3a|%3f|%3e|%3c|%2c|\.| %2f|%a3%bf|%a1%b7|%a1%b6|%a1%a2|%a1%a3|%a3%ac|%7d|%a1%b0|%a3%ba|%a3%bb|%a1%ae|%a1%af|%a1%b1|%a3%fc|%a3%bd|%a1% aa|%a3%a9|%a3%a8|%a1%ad|%a3%a4|%a1%a4|%a3%a1|%e3%80%82|%ef%bc%81|%ef%bc%8c|%ef%bc%9b|%ef%bc%9f|%ef%bc%9a|%e3% 80%81|%e2%80%a6%e2%80%a6|%e2%80%9d|%e2%80%9c|%e2%80%98|%e2%80%99|%ef%bd%9e|%ef%bc%8e|%ef%bc%88) +/", ', $text);
$text =urldecode ($text);
Return trim ($text);
}
We do data acquisition or verification process, often need to do some special data processing, such as the removal of Chinese and English punctuation, reference to the online method, the more reliable PHP removal in English and Chinese code as follows:
<?php
$keyword = "good". , Good learning php!!! ";
$keyword =urlencode ($keyword);//The keyword is encoded
$keyword =preg_replace ("/(%7e|%60|%21|%40|%23|%24|%25|%5e|%26|%27|%2a |%28|%29|%2b|%7c|%5c|%3d|\-|_|%5b|%5d|%7d|%7b|%3b|%22|%3a|%3f|%3e|%3c|%2c|\.| %2f|%a3%bf|%a1%b7|%a1%b6|%a1%a2|%a1%a3|%a3%ac|%7d|%a1%b0|%a3%ba|%a3%bb|%a1%ae|%a1%af|%a1%b1|%a3%fc|%a3%bd|%a1% aa|%a3%a9|%a3%a8|%a1%ad|%a3%a4|%a1%a4|%a3%a1|%e3%80%82|%ef%bc%81|%ef%bc%8c|%ef%bc%9b|%ef%bc%9f|%ef%bc%9a|%e3% 80%81|%e2%80%a6%e2%80%a6|%e2%80%9d|%e2%80%9c|%e2%80%98|%e2%80%99) +/", ', $keyword);
$keyword =urldecode ($keyword);//to decode the filtered keyword
echo $keyword;
Output results:
Learn PHP Well