php - Find regular loop matching
高洛峰
高洛峰 2017-05-16 13:16:57
0
4
478
 <dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbc8ups.html" target="_blank">20170408$http://www.iqiyi.com/v_19rrbc8ups.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbd47ic.html" target="_blank">20170407$http://www.iqiyi.com/v_19rrbd47ic.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrnfp1nk.html" target="_blank">20170407$http://www.iqiyi.com/v_19rrnfp1nk.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbcsn9g.html" target="_blank">20170406$http://www.iqiyi.com/v_19rrbcsn9g.html</a></dd>

I want to loop through the value in the a tag, such as:
20170408$http://www.iqiyi.com/v_19rrbc...
20170407$http://www.iqiyi.com /v_19rrbd...

How should

be written?

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(4)
世界只因有你
preg_match_all('/(\d{8}\$[^<]+)/', $subject, $result, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($result[0]); $i++) {
    # Matched text = $result[0][$i];
}
刘奇

It feels so cumbersome to use regular expressions to do this. Can you directly search for tags like this:

var a = document.querySelectorAll('a');
        a.forEach((item)=>{
            console.log(item.innerText);
        })
刘奇
$string = '<dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbc8ups.html" target="_blank">20170408$http://www.iqiyi.com/v_19rrbc8ups.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbd47ic.html" target="_blank">20170407$http://www.iqiyi.com/v_19rrbd47ic.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrnfp1nk.html" target="_blank">20170407$http://www.iqiyi.com/v_19rrnfp1nk.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbcsn9g.html" target="_blank">20170406$http://www.iqiyi.com/v_19rrbcsn9g.html</a></dd>';

$ret = preg_match_all('#(<a.*?>)(.*?)(</a>)#', $string, $matchs);

var_dump($matchs);
过去多啦不再A梦
$pattern = '/<a[^>]*>([^<]*)<\/a>/';
$temp = preg_match_all($pattern, $html, $match);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template