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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find South African ID Number
Expression
(((\d{2}((0[13578]|1[02])(0[1-9]|[12]\d|3[01])|(0[13456789]|1[012])(0[1-9]|[12]\d|30)|02(0[1-9]|1\d|2[0-8])))|([02468][048]|[13579][26])0229))(( |-)(\d{4})( |-)(\d{3})|(\d{7}))
Description
Validates South African ID Numbers
Matches
771125 5047 081 | 771231-5046-081 | 7712315046081
Non-Matches
non valid id numbers
Author Rating: The rating for this expression. Chris Morton
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: Not that great
Name: Jerome Viveiros
Date: 5/30/2014 3:45:02 AM
Comment:
According to this expression, 1111111111111 is a valid SA ID.


Title: Not that great
Name: Jerome Viveiros
Date: 5/30/2014 3:41:06 AM
Comment:
According to this expression, 1111111111111 is a valid SA ID.


Title: Adjustment
Name: Jacques
Date: 9/11/2013 11:29:27 AM
Comment:
Hi Chris,I just came across this now, it looks great I have read most articles where they say the 11th digit is 0 for SA citizen and 1 for foreign, would I be correct then in assuming you can change the code to instead of specifying 0-9 you could 0-1 (?<Year>[0-9][0-9])(?<Month>([0][1-9])|([1][0-2]))(?<Day>([0-2][0-9])|([3][0-1]))(?<Gender>[0-9])(?<Series>[0-9]{3})(?<Citizenship>[0-1])(?<Uniform>[0-9])(?<Control>[0-9]) Thanks for the great work!


Title: Adjustment
Name: Jacques
Date: 9/11/2013 11:28:52 AM
Comment:
Hi Chris,I just came across this now, it looks great I have read most articles where they say the 11th digit is 0 for SA citizen and 1 for foreign, would I be correct then in assuming you can change the code to instead of specifying 0-9 you could 0-1 (?<Year>[0-9][0-9])(?<Month>([0][1-9])|([1][0-2]))(?<Day>([0-2][0-9])|([3][0-1]))(?<Gender>[0-9])(?<Series>[0-9]{3})(?<Citizenship>[0-1])(?<Uniform>[0-9])(?<Control>[0-9]) Thanks for the great work!


Title: true religion sale
Name: YIHONG1
Date: 11/13/2012 2:43:02 AM
Comment:
Theretrue religion jeans sale are usually different Correct Religious beliefs Denims factors in which determine which usually with all the atrue religion jeans on sale lots of juicers in the marketplace will be the proper juicer for you personally discount true religion jeans.


Title: true religion sale
Name: YIHONG1
Date: 11/13/2012 2:42:35 AM
Comment:
Theretrue religion jeans sale are usually different Correct Religious beliefs Denims factors in which determine which usually with all the atrue religion jeans on sale lots of juicers in the marketplace will be the proper juicer for you personally discount true religion jeans.


Title: SAIDValidator
Name: Willem Fourie
Date: 4/12/2012 7:13:08 AM
Comment:
Check out these links: http://geekswithblogs.net/willemf/archive/2005/10/30/58561.aspx http://xml-fx.com/services/saidvalidator/TestPage.aspx


Title: SAIDValidator
Name: Willem Fourie
Date: 4/12/2012 7:12:45 AM
Comment:
Check out these links: http://geekswithblogs.net/willemf/archive/2005/10/30/58561.aspx http://xml-fx.com/services/saidvalidator/TestPage.aspx


Title: Author
Name: Chris Morton
Date: 1/5/2012 10:17:03 AM
Comment:
Hi Tony Wilkinson, please refer to this sites testing functionality and retest with your id number...


Title: Mr
Name: Tony Wilkinson
Date: 2/22/2011 5:15:33 AM
Comment:
This doesn't validate the 13th digit.


Title: validator class
Name: Dusty Roberts
Date: 1/7/2011 4:57:51 AM
Comment:
you can have a look at this helper class to validate ID Numbers: http://www.polemus.net/2011/01/getting-information-from-south-african.html


Title: south african id number check sum code
Name: chris morton
Date: 12/15/2008 7:41:32 AM
Comment:
#region Copyright (c) 2006 Synerics Business Solutions /* (c) 2006 Synerics Business Solutions code@synerics.com www.synerics.com This software is provided 'as-is', without any warranty. Permission is granted to anyone to use this software for any purpose. This notice may not be removed from any source distribution; if you are using this software in a product, this notice should be included in materials distributed with your product. */ #endregion using System; using System.Text; using System.Text.RegularExpressions; namespace Foundation.Utils { /// <summary> /// Validates a South African identity number. /// </summary> public class IDValidator { // constants const int VALID_LENGTH = 13; const int CONTROL_DIGIT_LOCATION = 12; const int CONTROL_DIGIT_CHECK_VALUE = 10; const int CONTROL_DIGIT_CHECK_EXCEPTION_VALUE = 9; const string REGEX_ID_PATTERN = "(?<Year>[0-9][0-9])(?<Month>([0][1-9])|([1][0-2]))(?<Day>([0-2][0-9])|([3][0-1]))(?<Gender>[0-9])(?<Series>[0-9]{3})(?<Citizenship>[0-9])(?<Uniform>[0-9])(?<Control>[0-9])"; const bool VALID = true; const bool INVALID = false; // member variables private string id; // constructor public IDValidator(string id_) { id = id_; } public int GetAge() { if (isValid()) { DateTime birthDate = DateTime.ParseExact(id.Substring(0,2) + "/" + id.Substring(2,2) + "/" + id.Substring(4,2), "yy/MM/dd", System.Globalization.CultureInfo.InvariantCulture); int years = DateTime.Now.Year - birthDate.Year; if (years < 0) { birthDate = DateTime.ParseExact("19" + id.Substring(0, 2) + "/" + id.Substring(2, 2) + "/" + id.Substring(4, 2), "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture); years = DateTime.Now.Year - birthDate.Year; } if (DateTime.Now.Month < birthDate.Month || (DateTime.Now.Month == birthDate.Mon


Title: south african id number check sum code
Name: chris morton
Date: 12/15/2008 7:02:25 AM
Comment:
#region Copyright (c) 2006 Synerics Business Solutions /* (c) 2006 Synerics Business Solutions code@synerics.com www.synerics.com This software is provided 'as-is', without any warranty. Permission is granted to anyone to use this software for any purpose. This notice may not be removed from any source distribution; if you are using this software in a product, this notice should be included in materials distributed with your product. */ #endregion using System; using System.Text; using System.Text.RegularExpressions; namespace Foundation.Utils { /// <summary> /// Validates a South African identity number. /// </summary> public class IDValidator { // constants const int VALID_LENGTH = 13; const int CONTROL_DIGIT_LOCATION = 12; const int CONTROL_DIGIT_CHECK_VALUE = 10; const int CONTROL_DIGIT_CHECK_EXCEPTION_VALUE = 9; const string REGEX_ID_PATTERN = "(?<Year>[0-9][0-9])(?<Month>([0][1-9])|([1][0-2]))(?<Day>([0-2][0-9])|([3][0-1]))(?<Gender>[0-9])(?<Series>[0-9]{3})(?<Citizenship>[0-9])(?<Uniform>[0-9])(?<Control>[0-9])"; const bool VALID = true; const bool INVALID = false; // member variables private string id; // constructor public IDValidator(string id_) { id = id_; } public int GetAge() { if (isValid()) { DateTime birthDate = DateTime.ParseExact(id.Substring(0,2) + "/" + id.Substring(2,2) + "/" + id.Substring(4,2), "yy/MM/dd", System.Globalization.CultureInfo.InvariantCulture); int years = DateTime.Now.Year - birthDate.Year; if (years < 0) { birthDate = DateTime.ParseExact("19" + id.Substring(0, 2) + "/" + id.Substring(2, 2) + "/" + id.Substring(4, 2), "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture); years = DateTime.Now.Year - birthDate.Year; } if (DateTime.Now.Month < birthDate.Month || (DateTime.Now.Month == birthDate.Mon


Title: south african id number check sum code
Name: chris morton
Date: 12/15/2008 7:01:35 AM
Comment:
#region Copyright (c) 2006 Synerics Business Solutions /* (c) 2006 Synerics Business Solutions code@synerics.com www.synerics.com This software is provided 'as-is', without any warranty. Permission is granted to anyone to use this software for any purpose. This notice may not be removed from any source distribution; if you are using this software in a product, this notice should be included in materials distributed with your product. */ #endregion using System; using System.Text; using System.Text.RegularExpressions; namespace Foundation.Utils { /// <summary> /// Validates a South African identity number. /// </summary> public class IDValidator { // constants const int VALID_LENGTH = 13; const int CONTROL_DIGIT_LOCATION = 12; const int CONTROL_DIGIT_CHECK_VALUE = 10; const int CONTROL_DIGIT_CHECK_EXCEPTION_VALUE = 9; const string REGEX_ID_PATTERN = "(?<Year>[0-9][0-9])(?<Month>([0][1-9])|([1][0-2]))(?<Day>([0-2][0-9])|([3][0-1]))(?<Gender>[0-9])(?<Series>[0-9]{3})(?<Citizenship>[0-9])(?<Uniform>[0-9])(?<Control>[0-9])"; const bool VALID = true; const bool INVALID = false; // member variables private string id; // constructor public IDValidator(string id_) { id = id_; } public int GetAge() { if (isValid()) { DateTime birthDate = DateTime.ParseExact(id.Substring(0,2) + "/" + id.Substring(2,2) + "/" + id.Substring(4,2), "yy/MM/dd", System.Globalization.CultureInfo.InvariantCulture); int years = DateTime.Now.Year - birthDate.Year; if (years < 0) { birthDate = DateTime.ParseExact("19" + id.Substring(0, 2) + "/" + id.Substring(2, 2) + "/" + id.Substring(4, 2), "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture); years = DateTime.Now.Year - birthDate.Year; } if (DateTime.Now.Month < birthDate.Month || (DateTime.Now.Month == birthDate.Mon


Title: Mr
Name: Gary
Date: 11/10/2008 4:31:36 AM
Comment:
this is great, it even checks leap years, days, very very nice, thanks chris


Title: South African ID Number
Name: Chris
Date: 9/10/2007 4:19:05 AM
Comment:
Hi Chris. That is a very impressive regex, but unfortunately it doesn't check for the south african id number checksum. I don't know if it is even possible with regex. Regards, Chris


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