Skip to content

Instantly share code, notes, and snippets.

View lipe-dev's full-sized avatar

Felipe Israel Camargo Pereira lipe-dev

View GitHub Profile
@lipe-dev
lipe-dev / canada-driver-license-numbers.js
Last active March 9, 2023 11:19
Regexes for all US states and Canada provinces driver licenses. Each one has their own rules.
// Some info based on: https://learn.microsoft.com/en-us/microsoft-365/compliance/sit-defn-canada-drivers-license-number?view=o365-worldwide
const canadaDLNumberPatterns = {
Alberta: /\d{6}-\d{3}|\d{5,9}/,
"British Columbia": /\d{7}/,
Manitoba: /\w{2}-?\w{2}-?\w{2}-?\w\d{3}\w{2}/,
"New Brunswick": /\d{5,7}/,
"Newfoundland and Labrador": /\w\d{9}/,
"Nova Scotia": /\w{5}-?[0123]\d[01]\d{6}/,
Ontario: /\w\d{4}-?\d{5}\d[0156]\d[0123]\d/,