Regular expressions met \n
Ik heb een probleem met een script.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
$html = file_get_contents("http://one2xs.com/");
preg_match_all('/ <div class="topic-bericht-container" id="postlist_(.*?)">
<div class="topic-gebruikersinhoud">
<span class="topic-usernaam">(.*?) <a href="http:\/\/www.one2xs.com\/profiel\/bekijk?gebruiker=(.*?)">(.*?)<\/a><\/span><br \/>
<span class="topic-userstatus">
Adverteerder <\/span><br \/>
<img class="topic-avatar" src="http:\/\/www.one2xs.com\/img\/avatars\/(.*?).gif" alt="Avatar" border="0" \/> <br \/>
<div class="topic-userinformatie">
(.*?)<br \/>
(.*?) <br \/><span style="cursor: pointer;" onclick="window.location='http:\/\/www.one2xs.com\/profiel\/feedback?gebruiker=(.*?)';"><img src="http:\/\/www.one2xs.com\/img\/goedkeuren_klein.png" alt="" align="absmiddle" style="padding: 0 0 2px 0;" \/>(.*?)<img src="http:\/\/www.one2xs.com\/img\/afkeuren_klein.png" alt="" style="padding: 0 0 2px 0;" align="absmiddle" \/>(.*?)<\/span> <\/div>
<\/div>
<div class="topic-bericht">
<div id="bericht_(.*?)">
(.*?)<\/div> <hr size="1" noshade="noshade" color="#deac68" \/>
<div class="topic-sig">
(.*?)
<\/div>
<\/div>
<div style="clear: both"><\/div>
<\/div> /', $html, $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
echo "" . $val[0] . "\n";
echo "Tekst: " . $val[1] . "\n";
}
?>
$html = file_get_contents("http://one2xs.com/");
preg_match_all('/ <div class="topic-bericht-container" id="postlist_(.*?)">
<div class="topic-gebruikersinhoud">
<span class="topic-usernaam">(.*?) <a href="http:\/\/www.one2xs.com\/profiel\/bekijk?gebruiker=(.*?)">(.*?)<\/a><\/span><br \/>
<span class="topic-userstatus">
Adverteerder <\/span><br \/>
<img class="topic-avatar" src="http:\/\/www.one2xs.com\/img\/avatars\/(.*?).gif" alt="Avatar" border="0" \/> <br \/>
<div class="topic-userinformatie">
(.*?)<br \/>
(.*?) <br \/><span style="cursor: pointer;" onclick="window.location='http:\/\/www.one2xs.com\/profiel\/feedback?gebruiker=(.*?)';"><img src="http:\/\/www.one2xs.com\/img\/goedkeuren_klein.png" alt="" align="absmiddle" style="padding: 0 0 2px 0;" \/>(.*?)<img src="http:\/\/www.one2xs.com\/img\/afkeuren_klein.png" alt="" style="padding: 0 0 2px 0;" align="absmiddle" \/>(.*?)<\/span> <\/div>
<\/div>
<div class="topic-bericht">
<div id="bericht_(.*?)">
(.*?)<\/div> <hr size="1" noshade="noshade" color="#deac68" \/>
<div class="topic-sig">
(.*?)
<\/div>
<\/div>
<div style="clear: both"><\/div>
<\/div> /', $html, $matches, PREG_SET_ORDER);
foreach ($matches as $val) {
echo "" . $val[0] . "\n";
echo "Tekst: " . $val[1] . "\n";
}
?>
Dit script wil geen \n matchen. (Volgens de tut die ik had gelezen.)
Maar hoe moet ik dan (.*?) vervangen.
Want het klopt er komt niks uit. terwijl er wel iets uit hoort te komen.
Ik snap dat niet helemaal.