preg_replace用于特殊格式,例如“[m; 9; 34; 1m”

时间:2013-09-22 21:20:21

标签: php regex preg-replace

我找不到任何PHP Regex清除此字符串:

“[21m [0; 34; 1m [21m [HoaxPvP] [m [21m [0; 32; 1mhi [m] 至: “[HoaxPvP] hi”

如果你找到了正则表达式,请提前感谢。

2 个答案:

答案 0 :(得分:1)

preg_replace('/\[[\d;]*m/', '', '[21m[0;34;1m[21m[HoaxPvP][m [21m[0;32;1mhi[m');

答案 1 :(得分:1)

$subject = preg_replace('/\x1b(\[|\(|\))[;?0-9]*[0-9A-Za-z]/', "",$subject); 
$subject = preg_replace('/[\x03|\x1a]/', "", $subject);