c# - Identity cards number validation -


i want validate national identity card number small application.

there 9 digits there letter @ end 'x' or 'v' (both capital , simple letters) 3rd digit can not equal 4 or 9 

how can validate using visual studio 2010? can use regular expression validate this?

you can without regex like:

string str = "124456789x"; if ((str.count(char.isdigit) == 9) && // 9 digits     (str.endswith("x", stringcomparison.ordinalignorecase)      || str.endswith("v", stringcomparison.ordinalignorecase)) && //a letter @ end 'x' or 'v'     (str[2] != '4' && str[2] != '9')) //3rd digit can not equal 4 or 9 {     //valid  } else {     //invalid } 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -