I’m trying to create a regex to match the productCode of this table
So, near as I can tell.l…
Its an 8 characters in length, starts with an S, then a two digit number between 00 and 20, then a _, followed by 4 digits
Hows this?
//Grab the GET & test it using regex.
$code = $_GET['Code'];
$pattern = '/^S[0-20]_\d{8}/';
if (preg_match($pattern, $code)) {
echo "<h1>Product Found</h1>";
} else {
echo '<h3>';
echo 'Where did that product come from, cause we dont have it.';
echo '</h3>';
}
how far am I off?