如何检查用户输入数据是否不是英语?

Saf*_*Ali 1 asp.net facebook

我在我的应用程序中使用Facebook API进行用户身份验证,然后将用户数据保存到数据库中.我正在为我的应用程序使用相同的(即facebook)用户名,如果它存在,我使用名称创建用户名,但问题是某些用户没有英文显示名称.那么如何在服务器端检查这样的输入呢?

我的应用程序是用Asp.net编写的.

Cos*_*min 5

您可以使用正则表达式来检查字符是否仅为a, b, c...zA, B, C...Z:

using System.Text.RegularExpressions;

Regex rgx = new Regex("^[a-zA-Z]+$");

if (rgx.IsMatch(inputData))
   // input data is in English alphabet; take appropriate action...
else
   // input data is not in English alphabet; take appropriate action...
Run Code Online (Sandbox Code Playgroud)