【发布时间】:2015-01-16 23:51:57
【问题描述】:
我正在寻找一种使用 C# 在字符串中检测信用卡的方法。正则表达式是一种可能性。我不想检测字符串是否是信用卡。
例如
string text = "Hi mum, here is my credit card 1234-1234-1223-1234. Don't tell anyone";
bool result = TextContainsCreditCard(text);
if (result)
throw new InvalidOperationException("Don't give people your credit card!");
【问题讨论】:
-
我完全不清楚。
-
你为什么不使用
string.contains可能性? -
String.Contains 是否与正则表达式一起使用?信用卡可以是多种格式。
-
这就够了吗?
text.Contains("credit card");-) -
这对您有帮助吗:stackoverflow.com/questions/72768/… ?