Evaluate a regular expression! -Php Tutorial

Source: Internet
Author: User
Evaluate a regular expression!

  • Xxx

  • Xxx

  • Xxx



  • Xxx

  • Xxx

  • Xxx



I want to obtain the contents of every li in UL with ID B in the regular expression. how should I write the regular expression?

/
    .*? (.*?) <\/Li> .*? <\/Ul>/is can only match the content in the first li


    Reply to discussion (solution)

    $s=<<
       
    • xxx
    • xxx
    • xxx
    • Xxx
    • Xxx
    • Xxx
    Html; preg_match ('#
      (. +)
    # Is ', $ s, $ m); preg_match_all ('# ] *> (. +)# IsU ', $ m [1], $ arr); print_r ($ arr [1]);

    Does it matter twice?

    Limited capabilities. it's hard to find other experts.

    Can't I use jquery?
    $ ('# B')-> find ('Ul ')-> find ('Lil') is what you want.

    (? <=

      (? : \ S * .*? <\/Li> \ s *) \ s * (.*?) <\/Li> \ s * to give you a reference. you can modify it as needed.

    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.