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);?>