Zitat von
DGL-luke:
Allerdings müssste mans noch schaffen, den status (waiting/up/down) in den selben index zu schieben.
Ja, escapen kann mans. Hier meine endgültige version, die leider etwas overhead produziert, dafür aber reines regex ist:
Code:
<pre>
<?php
$tests = array('status:up@ppX','status:waiting@ppX','status:down');
$exp = '/(?<=^status:) (((up|waiting|down)(@?)(.*?))) (?=$)/x';
foreach ($tests as $test)
{
preg_match($exp,$test,$matches);
print_r($matches);
print "\n";
}
?>
</pre>
Ergebnis:
Code:
Array
(
[0] => up@ppX
[1] => up@ppX
[2] => up@ppX
[3] => up
[4] => @
[5] => ppX
)
Array
(
[0] => waiting@ppX
[1] => waiting@ppX
[2] => waiting@ppX
[3] => waiting
[4] => @
[5] => ppX
)
Array
(
[0] => down
[1] => down
[2] => down
[3] => down
[4] =>
[5] =>
)
Status am Index 3, Server falls vorhanden an 5.
Ich werd mal sehen, ob man da noch was rauswerfen kann.
Lukas Erlacher
Suche Grafiktablett. Spenden/Gebrauchtangebote willkommen.
Gotteskrieger gesucht!
For it is the chief characteristic of the religion of science that it works. - Isaac Asimov, Foundation I, Buch 1