php正则" target="_blank">php正则


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>@

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


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3