RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

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
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

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}$


Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials