Hello, i want to use regex to validate the coupon format. I wrote the rules on regexr.com and it worked fine but not in php.
The expression i have: ([0-9]{3})+(-)+([0-9A-Z]{3})+(-)+([A-Z]{3})
Coupon format:
230-4WE-GAG
424-423-NJB
Basically the first 3 digits are numbers followed by a dash then 3 alphanumeric digits followed by a dash and at the end 3 characters
And the code i have:
(i'm using the rest library)
I know that PHP treats regex a little bit different but in which way?
The expression i have: ([0-9]{3})+(-)+([0-9A-Z]{3})+(-)+([A-Z]{3})
Coupon format:
230-4WE-GAG
424-423-NJB
Basically the first 3 digits are numbers followed by a dash then 3 alphanumeric digits followed by a dash and at the end 3 characters
And the code i have:
PHP Code:
if (preg_match('/([0-9]{3})+(-)+([0-9A-Z]{3})+(-)+([A-Z]{3})/', $coupon)) {
$coupon_data = $this->coupons->check_coupon($coupon);
$this->response($coupon_data, 200);
}
I know that PHP treats regex a little bit different but in which way?