Identity cards number validation

I want to validate National identity card number for my small application.

There are only 9 digits
there is a letter at the end 'x' or 'v' (both capital and simple letters)
3rd digit can not be equal to 4 or 9

How can I validate this using visual studio 2010? can I use regular expression to validate this?


You can do that without REGEX like:

string str = "124456789X";
if ((str.Count(char.IsDigit) == 9) && // only 9 digits
    (str.EndsWith("X", StringComparison.OrdinalIgnoreCase)
     || str.EndsWith("V", StringComparison.OrdinalIgnoreCase)) && //a letter at the end 'x' or 'v'
    (str[2] != '4' && str[2] != '9')) //3rd digit can not be equal to 4 or 9


Need Your Help

MSVC and FreeGlut Compiler Error

c++ static visual-c++ freeglut

Receiving alot of these messages when compiling which is making compiling a simple program very time consuming.

Parse iOS - How to query PFUser details from another class

ios xcode xcode6

I am trying to write a Parse query for my iOS social app that will show all users that are following the active user. Here is what I have so far: