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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^\d{3}\s?\d{3}\s?\d{3}$
Description
Social Insurance Number validator. Canadians only need apply. If somebody could help me (I'm bad at regex), I would like to modify this so that if there is one space after the 3rd digit (or 6th) then there must be one after the 6th (or third).
Matches
123 456 789 | 123456789 | 123 456789
Non-Matches
1234 5678 9 | 123 456 7890 | 123
Author Rating: Not yet rated. Matt Martens
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: validate your data
Name: Christian Caron
Date: 1/5/2004 1:20:48 PM
Comment:
The best is to make sure there are no space in it. Just remove all the non-numeric characters (s/[^0-9]//g).


Title: character after 3rd and 6th digit
Name: Michael Ash
Date: 12/19/2003 4:28:09 PM
Comment:
^\d{3}( ?)\d{3}\1\d{3}$ This will require the third and sixth digits, both or neither, be followed by a space.


Title: Try This
Name: Dean Dal Bozzo
Date: 12/18/2003 8:49:00 PM
Comment:
^\d{3}\s\d{3}\s\d{3}|\d{9}$ RegEx seem intimating at first but, the more you do them the eaiser they get.


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