Tagged Fiddles
((^[XYZ]\d{7,8}|^\d{8})[A-HJ-NP-TV-Z]$)
Simple regex to see if a string is a valid DNI/NIE number.
DNI/NIE numbers are spanish identification numbers. DNI are for spanish nationals and NIE are for foreigners living in Spain.
This will only take you so far. To fully verify the DNI/NIE you will have to:
DNI: Take the part in front of the letter. Convert it to a number. User modulus 23 on it. Use the result to index into TRWAGMYFPDXBNJZSQVHLCKE and see if the last letter matches (so for 01234567H you would run 1234567%23 = 19 and the 19:th char in the array is C, the number is not a valid DNI)
NIE: If the number is 8 digits long cut the leading letter and run the rest as if it was a DNI. If the number is 7 digits long change the leading letter to a number (X->0, Y->1, Z->2) and run it as if it was a DNI.
#+ Some simple tests
# Valid NIE format
X1234567G
Y0336380L
# Valid NIE, old format
X01234567H
X09375379G
# Valid DNI format
01234567J
39027217N
77122981W
37354021F
#- Random variations and common mistakes
G1234567G
X1234567U
1234567U
234567H
X-1234567G
01234567JJ
01234567j
/(^[XYZ]\d{7}\d?
Simple regex to see if a string is a valid DNI/NIE number.
DNI/NIE numbers are spanish identification numbers. DNI are for spanish nationals and NIE are for foreigners living in Spain.
This will only take you so far. To fully verify the DNI/NIE you will have to:
DNI: Take the part in front of the letter. Convert it to a number. User modulus 23 on it. Use the result to index into TRWAGMYFPDXBNJZSQVHLCKE and see if the last letter matches (so for 01234567H you would run 1234567%23 = 19 and the 19:th char in the array is C, the number is not a valid DNI)
NIE: If the number is 8 digits long cut the leading letter and run the rest as if it was a DNI. If the number is 7 digits long change the leading letter to a number (X->0, Y->1, Z->2) and run it as if it was a DNI.
#+ Some simple tests
# Valid NIE
X1234567G
# Valid, old NIE
X01234567H
X09375379G
# Valid DNI
01234567H
39027217N
77122981W
37354021F
46724451c
#- Random variations and common mistakes
G1234567G
X1234567U
1234567U
234567H
X-1234567G
42930307W
Simple regex to see if a string is a valid DNI/NIE number.
DNI/NIE numbers are spanish identification numbers. DNI are for spanish nationals and NIE are for foreigners living in Spain.
This will only take you so far. To fully verify the DNI/NIE you will have to:
DNI: Take the part in front of the letter. Convert it to a number. User modulus 23 on it. Use the result to index into TRWAGMYFPDXBNJZSQVHLCKE and see if the last letter matches (so for 01234567H you would run 1234567%23 = 19 and the 19:th char in the array is C, the number is not a valid DNI)
NIE: If the number is 8 digits long cut the leading letter and run the rest as if it was a DNI. If the number is 7 digits long change the leading letter to a number (X->0, Y->1, Z->2) and run it as if it was a DNI.
#+ Some simple tests
# Valid NIE format
X1234567G
Y0336380L
# Valid NIE, old format
X01234567H
X09375379G
# Valid DNI format
01234567J
39027217N
77122981W
37354021F
#- Random variations and common mistakes
G1234567G
X1234567U
1234567U
234567H
X-1234567G
01234567JJ
01234567j
/(^[XYZ]\d{7,8}|^\d{8})[A-HJ-NP-TV-Z]$/
Simple regex to see if a string is a valid DNI/NIE number.
DNI/NIE numbers are spanish identification numbers. DNI are for spanish nationals and NIE are for foreigners living in Spain.
This will only take you so far. To fully verify the DNI/NIE you will have to:
DNI: Take the part in front of the letter. Convert it to a number. User modulus 23 on it. Use the result to index into TRWAGMYFPDXBNJZSQVHLCKE and see if the last letter matches (so for 01234567H you would run 1234567%23 = 19 and the 19:th char in the array is C, the number is not a valid DNI)
NIE: If the number is 8 digits long cut the leading letter and run the rest as if it was a DNI. If the number is 7 digits long change the leading letter to a number (X->0, Y->1, Z->2) and run it as if it was a DNI.
#+ Some simple tests
# Valid NIE format
X1234567G
Y0336380L
# Valid NIE, old format
X01234567H
X09375379G
# Valid DNI format
01234567J
39027217N
77122981W
37354021F
#- Random variations and common mistakes
G1234567G
X1234567U
1234567U
234567H
X-1234567G
!((^[XYZ]\d{7,8}|^\d{8})[A-HJ-NP-TV-Z]$)
Simple regex to see if a string is a valid DNI/NIE number.
DNI/NIE numbers are spanish identification numbers. DNI are for spanish nationals and NIE are for foreigners living in Spain.
This will only take you so far. To fully verify the DNI/NIE you will have to:
DNI: Take the part in front of the letter. Convert it to a number. User modulus 23 on it. Use the result to index into TRWAGMYFPDXBNJZSQVHLCKE and see if the last letter matches (so for 01234567H you would run 1234567%23 = 19 and the 19:th char in the array is C, the number is not a valid DNI)
NIE: If the number is 8 digits long cut the leading letter and run the rest as if it was a DNI. If the number is 7 digits long change the leading letter to a number (X->0, Y->1, Z->2) and run it as if it was a DNI.
#+ Some simple tests
# Valid NIE format
X1234567G
Y0336380L
20-25922497-9
# Valid NIE, old format
X01234567H
X09375379G
# Valid DNI format
01234567J
39027217N
77122981W
37354021F
#- Random variations and common mistakes
G1234567G
X1234567U
1234567U
234567H
X-1234567G
01234567JJ
01234567j
!((^[XYZ]\d{7,8}|^\d{8})[A-HJ-NP-TV-Z]$)
This site has no rating
Simple regex to see if a string is a valid DNI/NIE number.
DNI/NIE numbers are spanish identification numbers. DNI are for spanish nationals and NIE are for foreigners living in Spain.
This will only take you so far. To fully verify the DNI/NIE you will have to:
DNI: Take the part in front of the letter. Convert it to a number. User modulus 23 on it. Use the result to index into TRWAGMYFPDXBNJZSQVHLCKE and see if the last letter matches (so for 01234567H you would run 1234567%23 = 19 and the 19:th char in the array is C, the number is not a valid DNI)
NIE: If the number is 8 digits long cut the leading letter and run the rest as if it was a DNI. If the number is 7 digits long change the leading letter to a number (X->0, Y->1, Z->2) and run it as if it was a DNI.
#+ Some simple tests
# Valid NIE format
X1234567G
Y0336380L
# Valid NIE, old format
X01234567H
X09375379G
# Valid DNI format
01234567J
39027217N
77122981W
37354021F
#- Random variations and common mistakes
G1234567G
X1234567U
1234567U
234567H
X-1234567G
012345
This site has no rating
x2792336k
/(^[XYZ]\d{7}\d?|^\d{8})[A-HJ-NP-TV-Z]$/
Simple regex to see if a string is a valid DNI/NIE number.
DNI/NIE numbers are spanish identification numbers. DNI are for spanish nationals and NIE are for foreigners living in Spain.
This will only take you so far. To fully verify the DNI/NIE you will have to:
DNI: Take the part in front of the letter. Convert it to a number. User modulus 23 on it. Use the result to index into TRWAGMYFPDXBNJZSQVHLCKE and see if the last letter matches (so for 01234567H you would run 1234567%23 = 19 and the 19:th char in the array is C, the number is not a valid DNI)
NIE: If the number is 8 digits long cut the leading letter and run the rest as if it was a DNI. If the number is 7 digits long change the leading letter to a number (X->0, Y->1, Z->2) and run it as if it was a DNI.
#+ Some simple tests
# Valid NIE
X1234567G
# Valid, old NIE
X01234567H
X09375379G
# Valid DNI
01234567H
39027217N
77122981W
37354021F
46724451C
#- Random variations and common mistakes
G1234567G
X1234567U
1234567U
234567H
X-1234567G
!((^[XYZ]\d{7,8}|^\d{8})[A-HJ-NP-TV-Z]$)
Simple regex to see if a string is a valid DNI/NIE number.
DNI/NIE numbers are spanish identification numbers. DNI are for spanish nationals and NIE are for foreigners living in Spain.
This will only take you so far. To fully verify the DNI/NIE you will have to:
DNI: Take the part in front of the letter. Convert it to a number. User modulus 23 on it. Use the result to index into TRWAGMYFPDXBNJZSQVHLCKE and see if the last letter matches (so for 01234567H you would run 1234567%23 = 19 and the 19:th char in the array is C, the number is not a valid DNI)
NIE: If the number is 8 digits long cut the leading letter and run the rest as if it was a DNI. If the number is 7 digits long change the leading letter to a number (X->0, Y->1, Z->2) and run it as if it was a DNI.
#+ Some simple tests
# Valid NIE format
X1234567G
Y0336380L
# Valid NIE, old format
X01234567H
X09375379G
# Valid DNI format
01234567J
39027217N
77122981W
37354021F
#- Random variations and common mistakes
G1234567G
X1234567U
1234567U
234567H
X-1234567G
01234567JJ
01234567j
Refiddle
Do you know PHP, Perl, Python or Java? View the docs to see
how you can help out
Tags
Displaying all 8 refiddles