Reguliere Expressie
Code (php)
1
2
3
4
5
2
3
4
5
<map name="map2" id="map2">
<area href="build.php?id=19" title="Pakhuis Niveau 6" coords="53,91,53,37,128,37,128,91,91,112" shape="poly"/><area href="build.php?id=20" title="Bouwplaats" coords="136,66,174,46,210,66,174,87" shape="poly"/><area href="build.php?id=21" title="Bouwplaats" coords="196,56,234,36,270,56,234,77" shape="poly"/><area href="build.php?id=22" title="Schuilplaats Niveau 10" coords="270,69,270,15,345,15,345,69,308,90" shape="poly"/><area href="build.php?id=23" title="Barakken Niveau 3" coords="327,117,327,63,402,63,402,117,365,138" shape="poly"/><area href="build.php?id=24" title="Bouwplaats" coords="14,129,52,109,88,129,52,150" shape="poly"/><area href="build.php?id=25" title="Bouwplaats" coords="97,137,135,117,171,137,135,158" shape="poly"/><area href="build.php?id=26" title="Hoofdgebouw Niveau 7" coords="182,119,182,65,257,65,257,119,220,140" shape="poly"/><area href="build.php?id=27" title="Bouwplaats" coords="337,156,375,136,411,156,375,177" shape="poly"/><area href="build.php?id=28" title="Graansilo Niveau 4" coords="2,199,2,145,77,145,77,199,40,220" shape="poly"/><area href="build.php?id=29" title="Academie Niveau 5" coords="129,164,129,110,204,110,204,164,167,185" shape="poly"/><area href="build.php?id=30" title="Bouwplaats" coords="92,189,130,169,166,189,130,210" shape="poly"/><area href="build.php?id=31" title="Stal Niveau 3" coords="342,216,342,162,417,162,417,216,380,237" shape="poly"/><area href="build.php?id=32" title="Bouwplaats" coords="22,238,60,218,96,238,60,259" shape="poly"/><area href="build.php?id=33" title="Ambassade Niveau 1" coords="167,232,167,178,242,178,242,232,205,253" shape="poly"/><area href="build.php?id=34" title="Bouwplaats" coords="290,251,328,231,364,251,328,272" shape="poly"/><area href="build.php?id=35" title="Wapensmid Niveau 3" coords="95,273,95,219,170,219,170,273,133,294" shape="poly"/><area href="build.php?id=36" title="Marktplaats Niveau 3" coords="222,284,222,230,297,230,297,284,260,305" shape="poly"/><area href="build.php?id=37" title="Bouwplaats" coords="80,306,118,286,154,306,118,327" shape="poly"/><area href="build.php?id=38" title="Bouwplaats" coords="199,316,237,296,273,316,237,337" shape="poly"/><area href="build.php?id=39" title="Verzamelplaats Niveau 1" coords="270,158,303,135,316,155,318,178,304,211,288,227,263,238,250,215" shape="poly" alt="" /> <area href="build.php?id=40" title="Muur van aarde Niveau 3" coords="312,338,347,338,377,320,406,288,421,262,421,222,396,275,360,311" shape="poly" alt="" />
<area href="build.php?id=40" title="Muur van aarde Niveau 3" coords="49,338,0,274,0,240,33,286,88,338" shape="poly" alt="" />
<area href="build.php?id=40" title="Muur van aarde Niveau 3" coords="0,144,34,88,93,39,181,15,252,15,305,31,358,63,402,106,421,151,421,93,378,47,280,0,175,0,78,28,0,92" shape="poly" alt="" />
</map>
<area href="build.php?id=19" title="Pakhuis Niveau 6" coords="53,91,53,37,128,37,128,91,91,112" shape="poly"/><area href="build.php?id=20" title="Bouwplaats" coords="136,66,174,46,210,66,174,87" shape="poly"/><area href="build.php?id=21" title="Bouwplaats" coords="196,56,234,36,270,56,234,77" shape="poly"/><area href="build.php?id=22" title="Schuilplaats Niveau 10" coords="270,69,270,15,345,15,345,69,308,90" shape="poly"/><area href="build.php?id=23" title="Barakken Niveau 3" coords="327,117,327,63,402,63,402,117,365,138" shape="poly"/><area href="build.php?id=24" title="Bouwplaats" coords="14,129,52,109,88,129,52,150" shape="poly"/><area href="build.php?id=25" title="Bouwplaats" coords="97,137,135,117,171,137,135,158" shape="poly"/><area href="build.php?id=26" title="Hoofdgebouw Niveau 7" coords="182,119,182,65,257,65,257,119,220,140" shape="poly"/><area href="build.php?id=27" title="Bouwplaats" coords="337,156,375,136,411,156,375,177" shape="poly"/><area href="build.php?id=28" title="Graansilo Niveau 4" coords="2,199,2,145,77,145,77,199,40,220" shape="poly"/><area href="build.php?id=29" title="Academie Niveau 5" coords="129,164,129,110,204,110,204,164,167,185" shape="poly"/><area href="build.php?id=30" title="Bouwplaats" coords="92,189,130,169,166,189,130,210" shape="poly"/><area href="build.php?id=31" title="Stal Niveau 3" coords="342,216,342,162,417,162,417,216,380,237" shape="poly"/><area href="build.php?id=32" title="Bouwplaats" coords="22,238,60,218,96,238,60,259" shape="poly"/><area href="build.php?id=33" title="Ambassade Niveau 1" coords="167,232,167,178,242,178,242,232,205,253" shape="poly"/><area href="build.php?id=34" title="Bouwplaats" coords="290,251,328,231,364,251,328,272" shape="poly"/><area href="build.php?id=35" title="Wapensmid Niveau 3" coords="95,273,95,219,170,219,170,273,133,294" shape="poly"/><area href="build.php?id=36" title="Marktplaats Niveau 3" coords="222,284,222,230,297,230,297,284,260,305" shape="poly"/><area href="build.php?id=37" title="Bouwplaats" coords="80,306,118,286,154,306,118,327" shape="poly"/><area href="build.php?id=38" title="Bouwplaats" coords="199,316,237,296,273,316,237,337" shape="poly"/><area href="build.php?id=39" title="Verzamelplaats Niveau 1" coords="270,158,303,135,316,155,318,178,304,211,288,227,263,238,250,215" shape="poly" alt="" /> <area href="build.php?id=40" title="Muur van aarde Niveau 3" coords="312,338,347,338,377,320,406,288,421,262,421,222,396,275,360,311" shape="poly" alt="" />
<area href="build.php?id=40" title="Muur van aarde Niveau 3" coords="49,338,0,274,0,240,33,286,88,338" shape="poly" alt="" />
<area href="build.php?id=40" title="Muur van aarde Niveau 3" coords="0,144,34,88,93,39,181,15,252,15,305,31,358,63,402,106,421,151,421,93,378,47,280,0,175,0,78,28,0,92" shape="poly" alt="" />
</map>
Uit dit stukje code wil ik graag met een match het id eruit halen en het bij behorende stukje titel. Voorbeeld: href="build.php?id=19" title="Pakhuis Niveau 6"
Wil ik dus het id: 19 eruit halen en de titel: Pakhuis Niveau 6
Ik heb nu dit:
Code (php)
1
2
3
2
3
preg_match_all('/<area href="build\.php\?id=(.+)" title="(.+)" coords=".+" shape=".+"\/>/', $content, $match);
print_r($match);
print_r($match);
Maar dat werkt dus niet :( Iemand ideeën?
Karl schreef op 20.10.2009 23:39:
/build.php\?id=(\d+)" title="((\w|\s|\d)+)"/
$match[1][$x] en $match[2][$x] wil je hebben.
Gemaakt met http://www.gskinner.com/RegExr/
$match[1][$x] en $match[2][$x] wil je hebben.
Gemaakt met http://www.gskinner.com/RegExr/
Je bent een held! Thx!