Obtain the matched characters in the Href attribute of A tag.
Obtain the Href attribute of A tag
Matched characters
Connection 1
Connection 2
Connection 3
You can use single quotes without quotation marks, but you cannot use either of them.
PHP code
preg_match('//i', $str, $matches)
Why not?
------ Solution --------------------
PHP code
$ Str = <
Connect 3 to 3STR; preg_match_all ('/] + href = (["\']?) ([^ \ S "\ '] +) \ 1 [^>] *>/', $ str, $ matches); print_r ($ matches [2]);
------ Solution --------------------
PHP code
$ Str = <
Connection 1
Connection 2
Connect 3 html; preg_match_all ('/href = (["\'])? ([^ \ S "\ '] +)/is', $ str, $ matches); print_r ($ matches );
------ Solution --------------------
PHP code
[User: root Time: 14: 14: 52 Path:/home/liangdong/php] $ php preg. php Array ([0] => Array ([0] =>
Array ([0] => "[1] => '[2] =>) [2] => Array ([0] => http://www.baidu.com/[1] => http://www.baidu.com/[2] => http://www.baidu.com/) [User: root Time: 14: 14: 53 Path:/home/liangdong/php] $ cat preg. php
Connection 1
Connection 2
Connect 3EOF; preg_match_all ('/