Find a simple PHP regular match.
- [Anime colleagues] Pokemon Black... text 22nd... 2826/18/0 Ding 13-08-29
- [Youth campus] Snow float in those years... the text is sincere. .. 202/5/0 renasha 13-08-29
In the above code, I only want the URL in the same format. How to write this regular expression.
I wrote the following,
$ Html = file_get_contents ($ setting ['Book _ url']);
$ K = '/
';
$ K. = '(. *) (. *) <\/a> (.*)';
$ K. = '<\/ul>/isu ';
Preg_match_all ($ k, $ html, $ rs );
No matching address
Reply to discussion (solution)
Preg_match_all ('#(.*?) <\/A> # I ', $ html, $ rs );
Write it directly.
#(.*)#
- [Anime colleagues] Pokemon Black... text 22nd... 2826/18/0 Ding 13-08-29
- [Youth campus] Snow float in those years... the text is sincere. .. 202/5/0 renasha 13-08-29
In the above code, I only want the URL in the same format. How to write this regular expression.
I wrote the following,
$ Html = file_get_contents ($ setting ['Book _ url']);
$ K = '/
';
$ K. = '(. *) (. *) <\/a> (.*)';
$ K. = '<\/ul>/isu ';
Preg_match_all ($ k, $ html, $ rs );
No matching address
Of course, your regular expression is '/
(. *) (. *) <\/A> (. *) <\/ul>/isU'
* Does not match the line break, but the html code
There are several spaces and line breaks behind
If you want to obtain ul in class = "main_con", we recommend that you use jquery for processing. It provides a variety of selectors, class selectors, and attribute selectors...
Test. php
$ Str = <
-
[Anime colleagues]
Pokemon Black...
Body 22nd...
2826/18/0
Ding
13-08-29
-
[Youth campus]
That year the snow floated...
The text is sincere...
202/5/0
Renasha
13-08-29
Html;
$ Pattern = "/
Preg_match_all ($ pattern, $ str, $ matches );
Var_dump ($ matches [1]);
?>
$ Matches [1] is the url array you want
#(.*)#