Beg for a regular expression! How to solve

Source: Internet
Author: User
Tags preg
Beg for a regular expression !!! The expression is used to extract the first url (the last id is the best), the hyperlink content, the question date and time, the hyperlink content next to it, and the number of answers, this requires preg_match_all loop Matching. please help me! & Lt; li & gt; & lt beg for a regular expression !!!
The expression is used to extract the first url (the last id is the best), the hyperlink content, the question date and time, the hyperlink content next to it, and the number of answers, this requires preg_match_all loop Matching. please help me!



  • I wipe, I wipe .
    I wipe, I wipe


    Question date: 18:06:58-kagakugizyutugakari I wipe-answer count: 0-reward: 50

    I wipe> I wipe




  • ------ Solution --------------------
    The result is displayed, that is, there are more points in the back-to-back process ~ Make it happen.
    PHP code
      
      
      
    I wipe, I wipe . I wipe, I wipe
    Question date: 18:06:58-kagakugizyutugakari I wipe-answer count: 0-reward: 50
    I wipe> I wipe
    HTML; $ pattern = '/question_detail \/([^ "] +)"> # The first id (. + ?) <\/A> # content of the first link. +? Question date: ([^-] +). +? # Question Time] +) <\/a> # content of the second link. +? Number of answers: (\ d +) # Number of answers/xis '; preg_match_all ($ pattern, $ str, $ matches); print_r ($ matches ); /* Array ([0] => Array ([0] => question_detail/q1187216696 "> I wipe and I wipe. Q: Why do I clean? Q: 2012/05/12 18:06:58-kagakugizyutugakari I clean-answer count: 0) [1] => Array ([0] => q1187216696) [2] => Array ([0] => I wipe, I wipe. [3] => Array ([0] => 2012/05/12 18:06:58) [4] => Array ([0] => kagakugizyutugakari) [5] => Array ([0] => 0 ))*/
    ------ Solution --------------------
    PHP code
    [User: root Time: 18: 44: 25 Path:/home/liangdong/php] $ php preg. php Array ([0] => I wipe my wipe. I wipe, I wipe[1] => q1187216696) Array ([0] =>
        
        
    Question date: 18:06:58-kagakugizyutugakari [1] => 18:06:58 [2] => kagakugizyutugakari) [User: root Time: 18: 44: 26 Path: /home/liangdong/php] $ cat preg. php
    I wipe, I wipe . I wipe, I wipe
    Question date: 18:06:58-kagakugizyutugakari I wipe-answer count: 0-reward: 50
    I wipe> I wipe
    EOF; $ nmatches = preg_match ('/. * <\/a>/Uis', $ str, $ matches); print_r ($ matches); $ nmatches = preg_match ('/
    . * (\ D {4} \ S + \ s + \ S +) \ s *-\ s *. *(. *) <\/a>/Uis ', $ str, $ matches); print_r ($ 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.