2014-04-01 27 views

回答

3
strlen(preg_replace('@[a-z0-9_\-\.]@', '', $string)); 

這首先去除所有字符你不想要:az,0-9 _和。通過preg_replace函數

preg_replace('@[a-z0-9_\-\.]@', '', $string); 

然後計算得到的字符串

+0

的長度我認爲OP希望刪除-Z0-9 ...而不是繼續使用它。刪除'^',它應該按需要工作。 – Typoheads

+0

謝謝@Typoheads,我的錯。現在將其固定 – mesutozer

+0

此代碼'的strlen(preg_replace函數( '@ [A-Z0-9 _ \ - \。] @', '',$字符串));' 將被刪除A-Z 0-9 - _。 – user3468464

相關問題