Title |
Test
Find
Swedish social security number (Svenskt personnummer)
|
Expression |
^(((20)((0[0-9])|(1[0-1])))|(([1][^0-8])?\d{2}))((0[1-9])|1[0-2])((0[1-9])|(2[0-9])|(3[01]))[-]?\d{4}$ |
Description |
Matches a Swedish social security number in format CCYYMMDD-NNNN, CCYYMMDDNNNN, YYMMDD-NNNN and YYMMDDNNNN on a single line. More useful version of my earlier expression. Will only match 1900 - 2011 years. |
Matches |
7712314582 | 810325-0782 | 19771231-4582 | 197712314582 |
Non-Matches |
137712314582 | 201211224567 | 10880215-0987 |
Author |
Rating:
Not yet rated.
Emil
|
Source |
|
Your Rating |
|
Title: How to match years over 2011?
Name: John
Date: 12/10/2020 11:04:02 AM
Comment:
I need to make this as future proof as possible so it needs to validate more than 2011
Title: Forgot about 10-19 for days
Name: Gustaf
Date: 11/11/2019 9:46:40 PM
Comment:
I believe you forgot about 10-19 dates.
This section: ((0[1-9])|(2[0-9])|(3[01]))
Should be: ((0[1-9])|(1[0-9])|(2[0-9])|(3[01]))
Title: You cannot have a birthday between 10-19
Name: Tiru
Date: 6/11/2014 6:37:54 AM
Comment:
This would be the correct validation:
^(((20)((0[0-9])|(1[0-4])))|(([1][^0-8])?\d{2}))((0[1-9])|1[0-2])((0[1-9])|(1[1-9])|(2[0-9])|(3[01]))[-]?\d{4}$