需求不明确,这样?string test = "Title=\"asdfsdf\""; Regex reg = new Regex(@"Title=""[^""]*"""); string result = reg.Replace(test, "");
string test = "Title=\"asdfsdf\""; System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"Title=""[^""]*"""); string result = reg.Replace(test, "Title=\"\""); Console.WriteLine(result);
{
string s = "asdfsdf";
s = Regex.Replace(s,@"\d+",new MatchEvaluator(CorrectString),RegexOptions.Compiled|RegexOptions.IgnoreCase);
Console.WriteLine(s);
Console.ReadLine();
}
private static string CorrectString(Match match)
{
string matchValue = match.Value;
if(matchValue.Length == 1)
matchValue = "";
return matchValue;
}
Regex reg = new Regex(@"Title=""[^""]*""");
string result = reg.Replace(test, "");
string test = "Title=\"asdfsdf\"";
System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"Title=""[^""]*"""); string result = reg.Replace(test, "Title=\"\"");
Console.WriteLine(result);