- 論壇徽章:
- 1
|
本帖最后由 umyspl 于 2010-05-13 00:56 編輯
- <?php
- $str =<<<EOF
- <description>
- <![CDATA[<a >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;
- }
- ?>
復(fù)制代碼 結(jié)果:
---------- php ----------
x![CDATA[xa >a linkx/a>]]>
Output completed (0 sec consumed)
你應(yīng)該回家好好讀讀手冊(cè)。
$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. |
|