suchen

Heim  >  Fragen und Antworten  >  Hauptteil

php – Regelmäßige Schleifenübereinstimmung finden

 <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>

Ich möchte den Wert im a-Tag durchlaufen, zum Beispiel:
20170408$http://www.iqiyi.com/v_19rrbc...
20170407$http://www.iqiyi.com/v_19rrbd...

Wie soll ich es schreiben?

高洛峰高洛峰2753 Tage vor483

Antworte allen(4)Ich werde antworten

  • 世界只因有你

    世界只因有你2017-05-16 13:18:57

    preg_match_all('/(\d{8}\$[^<]+)/', $subject, $result, PREG_PATTERN_ORDER);
    for ($i = 0; $i < count($result[0]); $i++) {
        # Matched text = $result[0][$i];
    }

    Antwort
    0
  • 怪我咯

    怪我咯2017-05-16 13:18:57

    用正则弄这个感觉好繁琐,能不能直接查找标签像下面这样:

    var a = document.querySelectorAll('a');
            a.forEach((item)=>{
                console.log(item.innerText);
            })

    Antwort
    0
  • 怪我咯

    怪我咯2017-05-16 13:18:57

    $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);

    Antwort
    0
  • 过去多啦不再A梦

    过去多啦不再A梦2017-05-16 13:18:57

    $pattern = '/<a[^>]*>([^<]*)<\/a>/';
    $temp = preg_match_all($pattern, $html, $match);

    Antwort
    0
  • StornierenAntwort