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
Post a Comment