Mailinglisten-Archive |
Hi Norbert,
Naja, das hängt immer von dem Problem ab. Ich hab unter anderen
Bedingungen getestet, als erforderlich war...
Hab darauf nochmal das Pattern bissel angepasst.
Hoffe, jetzt klappts:
<php>
$testarr = array('qwe69UNX1234512345asd',
'9UNX1234512345asd',
'qwe33UN 1234512345asd',
'qwe47URI1234512345asd',
'qwe47URN1234512345asd',
'qwe 7TUN1234512345asd');
$pattern =
'°([0-5][\d]|([^\d]|^)[\d]|60)[C-HJ-NP-X][A-HJ-NP-Z]{2}[\d]{10}°i';
foreach ($testarr as $subject)
{
echo $subject .' - ';
if (preg_match($pattern, $subject, $erg))
{
echo "<b>matches</b> (". $erg[0] .")<br>\n";
}
else
{
echo "no match<br>\n";
}
}
</php>
Ausgabe:
qwe69UNX1234512345asd - no match
9UNX1234512345asd - matches (9UNX1234512345)
qwe33UN 1234512345asd - no match
qwe47URI1234512345asd - no match
qwe47URN1234512345asd - matches (47URN1234512345)
qwe 7TUN1234512345asd - matches ( 7TUN1234512345)
Grüße und schönes Wochenende,
Niels Jäckel
php::bar PHP Wiki - Listenarchive