匹配html格式的正则!

WBOY
Release: 2016-06-13 11:05:31
Original
1499 people have browsed it

求一个匹配html格式的正则!!



  • 1

  • 2


Copy after login

请问可以用正则匹配出来这样一段HTML代码吗?我不会写正则,去网上看了点基础教程,匹配出来的结果只有
    里面的
  • 匹配不到(里面的li是不定数量的,可以能是2个,也会是更多~)。求高手帮忙写下正则!
    ------解决方案--------------------

    $str = 'afdasdfdsa

    • 1

    • 2

    asdfasdfasd

    • 3

    • 4

    fdsgsdfg';

    preg_match_all('/]*>.*<\/ul>/isU', $str, $matches);
    print_r($matches[0]);

    ?>
    Copy after login

    ------解决方案--------------------
    $str = '

    • 1

    • 2



    • 3



    • 4

    • 5

    • 6

    ';
    preg_match_all('/.*?<\/ul>/s', $str, $matches);
    var_dump($matches);
    Copy after login

  • Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!