I have to check if a string matches bio control numbers for products. This link has the specifications (unfortunatly in german).
The numbers start with a country-code, followed by 3 characters and two or three digits. Here some examples:
DE-ÖKO-233
IT-BIO-053
DK-ØKO-79
This is the regex, I came up with: /[A-Z]{2}-[A-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞŒŠŸ]{3}-\d{2,3}/
While it works perfectly fine on regex101.com, it doesn't work in my php-script as it returns an empty array.
$value = "DE-ÖKO-007";
preg_match('/[A-Z]{2}-[A-ZÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞŒŠŸ]{3}-\d{2,3}/', $value, $matches);
print_r($matches);
My expected output would be
Array(
[0] => "DE-ÖKO-007"
)
but I actually get
Array(
)
Am I missing something in the way preg_match
works?