Displaying page
of
pages;
Items to
Title |
Test
Details
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
|
Displaying page
of
pages;
Items to