-
- header("Content-type:text/html;charset=utf-8");
- $str = '';
- $pattern = "/[img|IMG].*?src=['|"](.*?(?:[.gif|.jpg] ))['|"].*?[/]?>/";
- preg_match_all($pattern,$str,$match);
- echo "";
- print_r($match);
- ?>
Copy the code
Attached, a summary of regular expressions for filtering html tags, attributes, etc. in PHP.
-
- function DeleteHtml($str)
- {
- $str = trim($str);
- $str = strip_tags($str,"");
- $str = ereg_replace("t","", $str);
- $str = ereg_replace("rn","",$str);
- $str = ereg_replace("r","",$str);
- $str = ereg_replace("n","" ,$str);
- $str = ereg_replace(" "," ",$str);
- return trim($str);
- }
Copy code
|