Matches regular expressions in html format!

Source: Internet
Author: User
Find a regular expression that matches the html format !! & Lt; ul & nbsp; & gt; & nbsp; & lt; li & gt; 1 & lt; li & gt; & nbsp; & lt; li & gt; 2 & lt; li & gt; & lt; ul & gt; can I use regular expressions to match such HTML code? I won't write regular expressions. I went to the internet and read some basic tutorials. the matching result is only a regular expression matching the html format !!


  • 1

  • 2



Can I use regular expressions to match such HTML code? I won't write regular expressions. I went to the internet and read some basic tutorials. the matching results are only
    Inside
  • No matching (the number of li in it is not fixed. it can be 2 or more ~). Please help write down the regular expression!
    ------ Solution --------------------
      
    $str = 'afdasdfdsa

    • 1

    • 2

    asdfasdfasd

    • 3

    • 4

    fdsgsdfg';

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

    ?>

    ------ Solution --------------------
      $str = '
      
      

    • 1

    • 2



    • 3



    • 4

    • 5

    • 6

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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.