Acquisition, more than 1 results for regular expressions

Source: Internet
Author: User
Acquisition, with more than 1 results for regular expressions,


    • 1

    • 2

    • 3

    • 4



Expression Get result/
  • (.*?)
  • /I matches multiple strips out. That's all.

    There is a question.

    Get only the first one.
    Or just get the last one.
    How do you write this?
    Get the first article that many people think will/
      .*
    • (.*?)
    • /Is there anything else besides this?



      Reply to discussion (solution)

      Match the first one
      You can use Preg_match.
      The last one can be used/

    • (.*?) <\/li>\s*<\/ul>/

      Match the first one
      You can use Preg_match.
      The last one can be used/

    • (.*?) <\/li>\s*<\/ul>/

      There are multiple (. *?) rules in the rule. , you need to return the array to do the processing.

      For example
      /
    • ^2013-(. *?) (.*?)
    • /
      In this case, do not need to start greedy mode U?
      And also need Preg_match_all?

      You're not going to get one, you can use Preg_match.

      There are multiple (. *?) rules in the rule. , you need to return the array to do the processing.
      Does this have an impact, for example to see.

      Preg_match_all returns an array, you can choose which result to use

      You're not going to get one, you can use Preg_match.

      There are multiple (. *?) rules in the rule. , you need to return the array to do the processing.
      Does this have an impact, for example to see.

      Tested. As you have said. Returning to do arrays is not affected.

      Preg_match_all returns an array, you can choose which result to use

      In fact, Preg_match_all and Preg_match are the same. One is to match all the appropriate. One is to match a suitable one.

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