110,538
社区成员
发帖
与我相关
我的任务
分享
if("ab{".StartWith("&#"))
{
....
}
string s = "abcd123";
string result = "";
Match ma = Regex.Match(s, @"(&#\d+)");
if (ma.Groups.Count == 1)
{
result = Regex.Replace(s, @"\d+", "");
}
MessageBox.Show(result);
string str = "abcd123";
string str1 = "ab{";
string result = Regex.Replace(str, @"(&#)?\d+", delegate(Match m) { if (string.IsNullOrEmpty(m.Groups[1].Value))return ""; else return m.Value; });
string result1 = Regex.Replace(str1, @"(&#)?\d+", delegate(Match m) { if (string.IsNullOrEmpty(m.Groups[1].Value))return ""; else return m.Value; });
Response.Write(result + "<br/>");
Response.Write(result1 + "<br/>");
/*
abcd
ab{
*/