- 论坛徽章:
- 1
|
本帖最后由 umyspl 于 2010-05-13 00:56 编辑
- <?php
- $str =<<<EOF
- <description>
- <![CDATA[<a href='http://xx.com'>a link</a>]]>
- </description>
- EOF;
- $str = preg_replace("/<description>((\n|\t|\r|.)*)<\/description>/ie", "search('\\1')", $str);
- echo $str;
- function search($match){
- $match = str_replace("<", "x", $match);
- return $match;
- }
- ?>
复制代码 结果:
---------- php ----------
x![CDATA[xa href='http://xx.com'>a linkx/a>]]>
Output completed (0 sec consumed)
你应该回家好好读读手册。
$str = preg_replace("/<description>((\n|\t|\r|.)*)<\/description>/ie", "search('\\1')", $str);
Example #4 Using the 'e' modifier
<?php
preg_replace("/(<\/?)(\w+)([^>]*>)/e",
"'\\1'.strtoupper('\\2').'\\3'",
$html_body);
?>
This would capitalize all HTML tags in the input text. |
|