uses
system.RegularExpressions;
function IsChineseName(const aName:string; const aMaxLength:Integer=10):Boolean; begin var Pattern := '^[\x{4E00}-\x{9FA5}]{2,'+aMaxLength.ToString+'}(·[\x{4E00}-\x{9FA5}]{2,'+aMaxLength.ToString+'}){0,2}$'; result:= TRegEx.Match(aName,Pattern).Success; end;
直接上代码了!
默认允许10个字的姓名,支持中间有分隔符“·”的姓名。
参数aMaxLength可以设置允许姓名的最大长度。
要引用system.RegularExpressions单元。
参考:
https://www.cnblogs.com/straybirds/p/6392306.html