Title |
Test
Find
Pattern Title
|
Expression |
^(X(-|\.)?0?\d{7}(-|\.)?[A-Z]|[A-Z](-|\.)?\d{7}(-|\.)?[0-9A-Z]|\d{8}(-|\.)?[A-Z])$ |
Description |
Matches Spanish CIF, NIF and NIE formats. Recognises separation of letters with the hyphen or period.
Format CIF: [1 letter][7 numbers][1 number or letter]
Format NIF: [8 numbers][1 letter]
Format NIE: X[possible 0][7 numbers][1 letter]
Note that this expression does not check for the validity of the NIF/CIF/NIE... there are some control characters in there and I don't know how they work.
Generally I always strip out any non-alphanumeric characters (hyphens, periods, etc.) and convert to upper case before checking validity and before saving to data storage.
Please post improvements or errors if you find them! |
Matches |
X01343567-D | B-6116622G | 43544122-R |
Non-Matches |
43.544.122-R |
Author |
Rating:
Not yet rated.
Greg Robbins
|
Source |
http://www.paginas-web-para-pymes.com/ |
Your Rating |
|
Title: improvement
Name: dave
Date: 3/13/2006 10:07:52 AM
Comment:
a complete ereg() pattern for NIF CIF and NIE from http://geocities.com/anoriaa/index.htm :
^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$