62,074
社区成员
发帖
与我相关
我的任务
分享
using System.Text.RegularExpressions;
string str = "HMNOV11001";
Regex re = new Regex("^[a-zA-Z]{5}\\d{7}$", RegexOptions.None);
bool flag = re.IsMatch(str);
private static bool CheckStr(string checkedStr)
{
return Regex.IsMatch(checkedStr, @"^[a-zA-Z]{5}\d{7}$");
}
<html>
<script type="text/javascript">
function Check()
{
var str =document.all.txtNum.value;
var reg = /^[a-zA-Z]{5}\d{7}$/;
alert(reg.test(str));
}
</script>
<body>
<div>
<input type="text" id="txtNum" value="AAAAA1234567" />
<input type="button" id="btn" onclick="Check();" value="Test"/>
</div>
</body>
</html>
string tempStr = "1MNOV1100001";//File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));
string pattern = @"^[a-zA-Z]{5}\d{7}$";
if (Regex.IsMatch(tempStr, pattern))
{
//满足条件
}
using System.Text.RegularExpressions;
string str = "HMNOV11001";
Regex re = new Regex("^[a-zA-Z]{5}\\d{7}$", RegexOptions.None);
bool flag = re.IsMatch(str) ? true : false;
Regex re = new Regex("^[a-zA-Z]{5}\\d{7}$", RegexOptions.None);
private static bool CheckStr(string checkedStr)
{
return Regex.IsMatch(checkedStr, @"^HMNOV\d{5}$", RegexOptions.IgnoreCase);
}
Regex re = new Regex("^HMNOV\\d{7}$", RegexOptions.IgnoreCase);
Regex re = new Regex("^HMNOV\\d{7}$");