1. mysql如何過濾特殊字元用PHP語言。高分求助,給補分
^function deletehtml($str) {
$str = trim($str);
$str = preg_replace("</P>","1234a3211",$str);
$str = preg_replace("</p>","1234a3211",$str);
$str = preg_replace("<br/>","1234a3211",$str);
$str = preg_replace("/<(.[^>]*)>/","",$str);
$str = preg_replace("/([\r\n])[\s]+/","",$str);
$str = preg_replace("/-->/","",$str);
$str = preg_replace("/<!--.*/","",$str);
$str = preg_replace("/&(quot|#34);/","",$str);
$str = preg_replace("/&(amp|#38);/", "/&/",$str);
$str = preg_replace("/&(lt|#60);/", "/</",$str);
$str = preg_replace("/&(gt|#62);/", ">",$str);
$str = preg_replace("/&(nbsp|#160);/", "",$str);
$str = preg_replace("/&(iexcl|#161);/", "/\xa1/",$str);
$str = preg_replace("/&(cent|#162);/", "/\xa2/",$str);
$str = preg_replace("/&(pound|#163);/", "/\xa3/",$str);
$str = preg_replace("/&(|#169);/", "/\xa9/",$str);
$str = preg_replace("/(\d+);/", "",$str);
$str = preg_replace("/</", "",$str);
$str = preg_replace("/>/", "",$str);
$str = preg_replace("/\r\n/", "",$str);
$str = preg_replace("/1234a3211/", "/<br/>/",$str);
return $str;
}
2. mysql中怎麼篩選出含有某個字元的數據並且替換
可以參考下列例子,將欄位1中含有的字元串'aaa'替換為'bbb'
update t1 set col1=replace(col1,'aaa','bbb');
3. Mysql怎麼篩選不以某串數字加一段字元串結尾的欄位
MySQL——使用正則表達式查詢
如果你會正則表達式的話,可以用正則表達式來過濾。
4. MYSQL 中 怎樣從字元串中提取 數字 也就是過濾掉非數字的字元~
單存用mysql 是實現不了的,如果加上php 就可以實現了!
php 直接把數據+0就可以取字元串裡面的數字了~