Skip to content

Instantly share code, notes, and snippets.

@RobSchilderr
Created December 22, 2021 08:21
Show Gist options
  • Save RobSchilderr/7467c00933d328bce33e1793b75bfa7b to your computer and use it in GitHub Desktop.
Save RobSchilderr/7467c00933d328bce33e1793b75bfa7b to your computer and use it in GitHub Desktop.
Common regular expressions for Dutch people, such as kvk number, iban, dutch identitycard
const regexps = {
alpha: '[a-zA-Z .-]+',
alphaNumeric: '[a-zA-Z0-9À-ü ,.\'-]+',
sameChars: /^(?!.*(.)\1\1+)/i,
date: /^(?:(?:(?:[0]?[1-9]|1[0-9]|2[0-8])-(?:(0)?[1-9]|1[0-2])|(?:29|30)-(?:(0)?[13-9]|1[0-2])|31-(?:(0)?[13578]|1[02]))-[1-9]\d{3}|29-(0)?2-(?:[1-9]\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00))$/,
kvkNumber: /^[0-9]{8}$/,
btwNumber: /^[A-Za-z]{2}[0-9]{9}[A-Za-z][0-9]{2}$/,
phoneMobile: /(^(\(?(0031|0|\+31)\)?){1})( ?-?(6){1}\)?)(( ?|-)?[1-9]( ?|-)?){1}(( ?|-)?[0-9]( ?|-)?){7}$/,
phoneFixedThreeDigits: /(^(\(?(0031|0|\+31)\)?){1})( ?-?([0-9]){3}\)?)(( ?|-)?[0-9]( ?|-)?){6}$/,
phoneFixedFourDigits: /(^(\(?(0031|0|\+31)\)?){1})( ?-?([0-9]){2}\)?)(( ?|-)?[0-9]( ?|-)?){7}$/,
phoneFixedExceptions: /^( ?\(?((0)|(\+31)|(0031))\)? ?){1}?(| |-| ?\([0-9]*?\) ?)(800|900|906|909){1}.*$/,
phoneFixedMobileException: /^( ?\(?((0)|(\+31)|(0031))\)? ?){1}?(| |-| ?\([0-9]*?\) ?)(800|900|906|909|6){1}.*$/,
zipCode: /^[1-9][0-9]{3}[ -\\.]?[A-Za-z]{2}$/,
houseNumber: /^[0-9]{0,5}$/,
houseNumberExtension: /^(?!\s|-)(((?!\s{2})[A-Za-z0-9\s-])*)$/,
iban: /^([A-Z]{2})(\d{2})([A-Z\d]+)$/,
driversLicense: /^(?!0{10})([0-9]{10})$/i,
identityCard: /^[a-zA-Z]{2}(?!0{7})([a-zA-Z0-9]{6}[0-9]{1})$/i,
passport: /^[a-np-z]{2}[a-np-z0-9]{6}[0-9]$/i,
email: /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
};
export default regexps;
@RobSchilderr
Copy link
Author

For SEO: Regular expressions for Kamer van Koophandel number, for Dutch identity card, for dutch passport, for IBAN number, for dutch zipcode's, for dutch driver license

@RobSchilderr
Copy link
Author

@RobSchilderr
Copy link
Author

Other option for phone number: /^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9])((\s|\s?-\s?)?[0-9])((\s|\s?-\s?)?[0-9])\s?[0-9]\s?[0-9]\s?[0-9]\s?[0-9]\s?[0-9]$/,

This matches:

Some valid examples as how Dutch people would write down their phonenumber:
0101234567
010-1234567
010 - 123 45 67
010 1234 567
06-12345678
06 123 456 78
0111-123456
0111 123456

International notation:
+31101234567
0031101234567
+31(0) 10123 4567

@mariusbosinceanu
Copy link

mariusbosinceanu commented Aug 10, 2024

Dear @RobSchilderr , hope the Regex-ies for Nederland didn't change since then. Anyway, thanks a lot !

BTW, I think for IBAN, the regex might be : /^NL[0-9]{2}[A-z0-9]{4}[0-9]{10}$/'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment