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
\b(((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}[,.]?\b
Description
Matches a Swedish social security number in format xxYYMMDD-NNNN, xxYYMMDD+NNNN, YYMMDD-NNNN, YYMMDD-NNNN and YYMMDDNNN. Does not allow birth years before 1900 and after 2011. To raise the birth year to higher level of birth just change the 1[0-1] part to i.e. 1[0-4] to allow birth years up to 2014 etc. This will find the SSN within a string. Also allow for a comma(,) or period(.) behind the SSN.
Matches
7712314582 | 810325+0782 | 19771231-4582
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: Dates between 10-19 fails
Name: Mattias
Date: 9/16/2014 10:52:36 AM
Comment:
Good work! You need to alter this slightly though, to make dates between the 10:th and the 19:th work. \b(((20)((0[0-9])|(1[0-1])))|(([1][^0-8])?\d{2}))((0[1-9])|1[0-2])((0[1-9])|(1[0-9])|(2[0-9])|(3[01]))[-+]?\d{4}[,.]?\b


Title: Trainer
Name: Jörgen Hjärtenflo
Date: 2/20/2013 12:35:24 PM
Comment:
Seems to work fine, until i tried 19111111-7777; or 111111-7777; If I try with 191121-7777 Everything works. I stumbled upon Another examples that didnt Went so well. If you have a temporary Swedish Coicail Security number, you will also have letter in your number. Buts its a good start!


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