比如匹配html中的a标签,正则代码如下:
<?php
$string="<html><a href='123.html'>链接1</a><a>链接2</a></html>";
preg_match_all( '/<a[^>]*(.*?)<\/a>/i', $string, $matches );
echo "<pre>";
print_r( $matches);
echo '</pre>';
网友回复
比如匹配html中的a标签,正则代码如下:
<?php
$string="<html><a href='123.html'>链接1</a><a>链接2</a></html>";
preg_match_all( '/<a[^>]*(.*?)<\/a>/i', $string, $matches );
echo "<pre>";
print_r( $matches);
echo '</pre>';
网友回复