PDA

View Full Version : preg_match not working


camarosource
08-24-2003, 12:13 AM
if (preg_match ("/1[2][3-6][37|67][7-9][L|N]\d\d\d\d\d\d/", $VIN)) {
echo "1967 - 1969 VIN entered";
} else {
echo "NOT a VALID 13 digit VIN entered";
exit;
}

This should be saying the following:

1st char = 1
2nd char = 2
3rd char = 3 - 6
4th & 5th chars = 36 or 67
6th char = 7 - 9
7th char = L or N
8th - 13th chars = NUMBERS

The problem resides in the [36|37]

How do I specify I want it to allow "36" or "67"?

mordred
08-25-2003, 11:25 PM
Don't specify a character class by using the square brackets, but use instead a group of two alternatives. So replace

[37|67]

with

(37|67)

and see if that helps.