如何使用正则表达式检查三个字符长度

How to check three character length using regular expression

本文关键字:三个 字符 何使用 正则表达式 检查      更新时间:2023-09-26
[RegularExpression(@"^.{3}$", ErrorMessage="Code should be Only three Chracter Length!")]

代码需要支持所有字母字符。我需要检查我的字符串长度应该是三个字母字符,但这对我不起作用。

对于正好 3 个字母字符的 Javascript 正则表达式匹配,您需要:

var matchResult = myString.match(/^[a-zA-Z]{3}$/);