I'm trying to build a regex to check if a valid VAT number for spain has been entered.
Altho, I can't seem to figure it out :(
A VAT number from spain looks like this:
ES + (# || A) + (7 x #) + (# || A)
ES = Country code
# = any digit from 0 - 9
A = any letter from a-z, A-Z
(# || A) means either a digit from 0-9 or an letter from a-z or A-Z
(7 x #) means 7 times any digit from 0-9
The catch here is that the first group (# || A) and the last group (# || A) cannot be numerical at the same time. One can be numerical and the other can be alphanumerical or the other way around or both can be alphanumerical at the same time.
Would anyone mind lending me a hand? Regex'es aren't really my thing :P
Thanks alot in advance!
My developer blog
View Complete Post