如何刪除/轉義特殊系統字符來回腳本如何刪除speacial字符,如:&)( /從字符串使用PHP
字符串的是
echo $position="marketing & executive cum \ stock ";
Outputs are: marketing & executive cum \ stock
但我想刪除後的結果? :?
output: marketing executive cum stock
它是如何更多鈔票
有任何解決方案,請幫助..
如何刪除/轉義特殊系統字符來回腳本如何刪除speacial字符,如:&)( /從字符串使用PHP
字符串的是
echo $position="marketing & executive cum \ stock ";
Outputs are: marketing & executive cum \ stock
但我想刪除後的結果? :?
output: marketing executive cum stock
它是如何更多鈔票
有任何解決方案,請幫助..
這個問題是這樣 Remove all special characters from a string 可能重複所以,請刪除此問題
使用的preg_replace(),你可以做到這一點
function cleanString($string) {
$string = str_replace(array('(', ')'), '', $string);
return preg_replace('/[^A-Za-z0-9\-]/', ' ', $string);
}
echo cleanString('marketing & executive cum \ stock ');
感謝它的作品,但我想刪除)(這些也請所以建議.. – Anuveester
檢查工作很好再次感謝 – Anuveester
@ Muthu17:這將是偉大的:https://eval.in/752861獲得單個空間 – C2486
使用後
$position="marketing & executive cum \ stock ";
echo preg_replace('/[^A-Za-z0-9\-\(\) ]/', '', $position);
它的工作,但想要刪除)(也是這樣如何可能 – Anuveester
@Anuveester:從正則表達式中刪除'\(\)'將工作 – C2486
preg_replace('/ [^ A-Za-z0-9 \ ] /','',$ position); – Karthik
可能的複製[正則表達式淨化(PHP)](http://stackoverflow.com/questions/3022185/regular-expression-sanitize-php) – v010dya