SIN (Canadian SSN) Validation Pattern
Created: 03 Oct 2012 | 2 comments
Running 10.0.0-7
Does a regular expression exist to validate a SIN (Canadian SSN) in content filtering?
There's not much point in using the basic regex as they block anything from 111-111-111 to 999-999-999 with zero validation.
I see a US SSN (Premium) pattern exists but not Canadian.
Here are some rules on SIN validation and a full perl example:
http://www.ryerson.ca/JavaScript/lectures/forms/textValidation/sinProject.html
http://cpansearch.perl.org/src/MANWAR/Algorithm-SIN-0.08/lib/Algorithm/SIN.pm
Thanks
Discussion Filed Under:
Comments 2 Comments • Jump to latest comment
Hello,
There's no pattern for Canada SIN by default but you can create your own pattern also.
I found a regex like this maybe this can help you to validate.
\b[1-9]\d{2}[- ]?\d{3}[- ]?\d{3}\b
Hi,
Thanks, there actually is one by default. It works but has zero validation.
The dictionnary isn't an option either as the text used in it could be legitimate in my case, just that normally it wouldn't contain any SIN info.
Thanks
Would you like to reply?
Login or Register to post your comment.