c# - Find a credit card within a string -


i looking way detect credit card within string using c#. regex possibility. not want detect if string credit card.

for example

string text = "hi mum, here credit card 1234-1234-1223-1234. don't tell anyone"; bool result = textcontainscreditcard(text); if (result)   throw new invalidoperationexception("don't give people credit card!"); 

you can use regex like

(\d{4}[\s-]?){4} 

and put chars want separator [\s-] space , minus

and allows separators in position (\d[\s-]?){16} 1 2341234-12341 234


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -