我想用正则表达式作验证
http://www.sg.com.cn/12312/123/aa.html (http://www.sg.com.cn/5位数字/3位数字/2位字符.html我写的正则表达式为
http://www.sg.com.cn/(\d{5}$)/(\d{3}$)/[:alpha:].html新手。刚刚用这个
http://www.sg.com.cn/12312/123/aa.html (http://www.sg.com.cn/5位数字/3位数字/2位字符.html我写的正则表达式为
http://www.sg.com.cn/(\d{5}$)/(\d{3}$)/[:alpha:].html新手。刚刚用这个
string strRegex = "http://www\\.sg\\.com\\.cn/\\d{5}/\\d{3}/\\S{2}.html";
这个
string regexStr = "http://www\\.sg\\.com\\.cn/\\d{5}/\\d{3}/\\S{2}\\.html";
漏了@
晕
string a=@"http://www[\.]sg[\.]com[\.]cn/([\d]{5})/([\d]{3})/([^\.]+?html)";
string b=@"http://www.sg.com.cn/12345/123/ss.html";
MatchCollection mc;
try
{
mc = Regex.Matches(b,a);
MessageBox.Show("搜索数目为"+mc.Count,"测试",MessageBoxButtons.OK,MessageBoxIcon.Information); }
catch
{
MessageBox.Show("正则表达式语法错误","测试失败",MessageBoxButtons.OK,MessageBoxIcon.Information);
}找到数目为0
tContent.action?id=[\d]{5}/[\d]{3}/[\S]{2}.html验证tContent.action?id=54321/321/ab.html