在asp.net中如何用正则表达式将 Title="asdfsdf"这样的标题全部替换成空字符串

解决方案 »

  1.   

    public static void Main() 
     { 
    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; 
      

  2.   

    需求不明确,这样?string test = "Title=\"asdfsdf\"";
    Regex reg = new Regex(@"Title=""[^""]*""");
    string result = reg.Replace(test, "");
      

  3.   


     string test = "Title=\"asdfsdf\"";
                System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(@"Title=""[^""]*""");            string result = reg.Replace(test, "Title=\"\"");
                Console.WriteLine(result);
      

  4.   

    用正则很慢的,建议直接用Replace函数