【发布时间】:2012-09-23 07:51:18
【问题描述】:
我必须对文本框中的文本进行一些模式匹配。我在 C# 服务器的回发事件中这样做。 我的正则表达式如下:
public bool ValidatePassword(string temp)
{
bool isMatch = false;
passwd = passwd.Trim();
isMatch = Regex.IsMatch(temp,
@"^ # Start of string
(?=.*\p{Lu}) # Assert at least one uppercase letter
(?=.*\p{Ll}) # Assert at least one lowercase letter
(?=.*\d) # Assert at least one digit
(?=.*[^\p{L}\d]) # Assert at least one other character
.{8,13} # Match at least 8 characters and maximum of 13 characters
$ # End of string",
RegexOptions.IgnorePatternWhitespace);
return isMatch;
}
我想将其移至 Javascript,以便在客户端进行匹配。有人可以帮我把这个函数移到 Javascript 上吗?
【问题讨论】:
-
这个link 可以帮助你。
-
\p{Lu}也将匹配 Unicode 字符的大写。模仿这种行为是可能的,但有点笨拙。
标签: c# javascript html regex client-side