Social-security-number matching : Regex SIN : Regular Expression C# Examples


C# Examples » Regular Expression » Regex SIN »

 

Social-security-number matching









    
using  System;
using  System.Collections.Generic;
using  System.Globalization;
using  System.Text;
using  System.Text.RegularExpressions;
using  System.Reflection;

public  class  MainClass{

      public  static  void  Main(){
                Regex  r1  =  new  Regex("[0-9]{3}-[0-9]{2}-[0-9]{4}");
                
                string  s  =  "011-01-0111";
                string  s2  =  "abc-01-0111";

                
                Console.WriteLine(r1.ToString());
                Console.WriteLine(r1.IsMatch(s));  
                Console.WriteLine(s2);
                Console.WriteLine(r1.IsMatch(s2));
      }
}
    
   
  
   



Output

[0-9]{3}-[0-9]{2}-[0-9]{4}
True
abc-01-0111
False


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Regular Expression
» Regex SIN