pro_php thread: regex
Try this...
Cheers,
Justin.
----
$test_array = array
(
"623456-gdfgdfgdfgfd",
"623456-54treeg",
"123-fdsOPOPPO",
"947386-gdfgdfgdfgfd",
" 623456-gdfgdfgdfgfd"
);
foreach ( $test_array as $str )
{
if ( preg_match("/^([0-9]{6}-.*)/",$str) )
{
echo "<b>Valid:</b> '$str'";
}
else
{
echo "<b>Not Valid:</b> '$str'";
}
echo "<p>";
}
|





