Ok I rewrote it a little with your input I think its correct now...lol...sorry very confuse by the results I'm getting 😕
<?
$self=$_SERVER['PHP_SELF']; # Get the Global
if($_POST['pattern']) {
$pattern=$_POST['pattern'];
$string=$_POST['string'];
if (preg_match($pattern,$string)) //preg_match or eregi
echo "$pattern pattern matches \"$string\"";
else
echo "$pattern pattern does not match \"$string\"";
}
?>
<html>
<body>
<h1>Testing Regular Expressions</h1>
<form action=<? echo "$self"; ?> method=POST>
String: <input type=text name="string" value="<? echo "$string"; ?>" size=30><br><br>
RegEx Pattern: <input type=text name="pattern" value="<? echo "$pattern"; ?>" size=30><br><br>
<input type=submit value="Test Pattern" name="Submit">
</form>
</body>
</html>
With preg_match
/[0-9]{6}$/ pattern matches "123456"
/[0-9]{6}$/ pattern does not match "12345"
/[0-9]{6}$/ pattern does not match "1234567"
now that makes sence....
So I tried it with
/[0-9]{2,12}$/ pattern matches "12"
/[0-9]{2,12}$/ pattern does not match "1"
/[0-9]{2,12}$/ pattern matches "123456789012"
/[0-9]{2,12}$/ pattern does not match "1234567890123"
All makes sence now :eek:
Thanks for you help