在我的应用程序中,我需要验证英语字符以及西班牙语字符,例如
· à
ç z Ë Ç
所以任何人请帮助我验证这种善意的信件.
您可以使用
p{L}
,描述Unicode字母字符的类。您可能需要使用额外的标志,具体取决于语言。
例如,这就是您在python中可以做的事情
import re
s = u"Sãràth S Pillai"
regex = r'[p{L}]*'
result = re.search(regex,s,re.UNICODE)
下面是 C# 中的示例代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
Regex regex = new Regex(@"[p{L}]*");
MatchCollection matches = regex.Matches("Sãràth S Pillài");
foreach (Match match in matches) {
try {
Console.WriteLine(match.Value);
}
catch { }
}
}
}
}