For a simple regular expression, see PHPcode $ content = & lt; html & lt; ulclass = & quot; small & quot; & gt; & lt; li & gt; & lt; ahref = & quot;/html5/tag_comment.as a simple regular expression. For more information, see
PHP code
$content = <<
html;$parr = "/href=\"\/html5\/(.*)\"/i";preg_match_all($parr, $content, $result);var_dump($result);
The matched results are as follows:
String (30) "tag_comment.asp" title = "HTML 5"
String (15) "tag_doctype.asp"
The first includes the title attribute. My intention is to only take the value of the href attribute. what should I do?
------ Solution --------------------
$ Parr = "/href = \" \/html5 \/(.*?) \ "/I ";
Array (2 ){
[0] =>
Array (2 ){
[0] =>
String (29) "href ="/html5/tag_comment.asp ""
[1] =>
String (29) "href ="/html5/tag_doctype.asp ""
}
[1] =>
Array (2 ){
[0] =>
String (15) "tag_comment.asp"
[1] =>
String (15) "tag_doctype.asp"
}
}
------ Solution --------------------
I used this all the time and forgot where to find it. I can't understand it. just use it.
PHP code
'/(.+?)<\/a.*?>/sim'