php正则表达式取子字符串及替换

$b=preg_match(‘/<img.+?\/>/’,$hello,$a);

解释:使用正则表达式<img.+? 匹配$hello,并将匹配的数据放在数组$a中。返回参数是匹配的数量 。

 

$b=preg_replace(‘/<img.+?\/>/’,”,$hello);

解析:使用正则表达式进行替换,使用第二个参数替换$hello匹配正则表达式的数据。替换后的字符串赋值给变量$b.

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>