首页 > 编程 > PHP > 正文

php正则

2019-11-22 01:53:00
字体:
来源:转载
供稿:网友

1  修饰符:好象没有讲
2  匹配模式好象有些少
比如<?php
$cp = preg_replace( "@<script(.*?)</script>@is", "", $cp );
            $cp = preg_replace( "@<iframe(.*?)</iframe>@is", "", $cp );
            $cp = preg_replace( "@<style(.*?)</style>@is", "", $cp );
?>出现"@<script(.*?)</script>@我就迷糊

希望得到帮助,多谢  

"@<script(.*?)</script>@

非贪婪模式,意思是匹配<script之后第一个<之间的东西,等价于@<script([^>]*)</script>@

有时候需要[^>]+?获取精确匹配。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表