PHP 正则表达式、反则轮换字符串
程序员文章站
2022-05-24 23:20:17
...
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
-
相关文章
相关视频
上一篇: 备份数据库