当前位置:Gxlcms > PHP教程 > PHP正则表达式、反则轮换字符串

PHP正则表达式、反则轮换字符串

时间:2021-07-01 10:21:17 帮助过:4人阅读

PHP 正则表达式、反则替换字符串

代码:

?

? //反则,保留除了A-Za-z0-9@\*的字符
??? $word = "6915-615@JPY11890*5822?" ;
??? $par = array('/[^A-Za-z0-9@\*]/');?
??? $word = preg_replace($par, "", $word);
??? echo ??? $word;
??? echo "
";


??? //正则,剔除A-Za-z0-9@\*字符
??? $word = "6915-615@JPY11890*5822?" ;
??? $par = array('/[A-Za-z0-9@\*]/');?
??? $word = preg_replace($par, "", $word);
??? echo ??? $word;


结果:

?

6915615@JPY11890*5822
-

人气教程排行