有没有过滤 和“&”开头“;”结束的这些标签的正则表达式啊?

解决方案 »

  1.   

    如无必要,这个最好还是不要用正则来做string yourStr = ...............;
    string result = Regex.Replace(yourStr, @"&\w+;", "");
      

  2.   

    试试这个看看
    string sourceString = @"   ";
    string pattern = @"&[^;]*;";
    System.Text.RegularExpressions.MatchCollection results = Regex.Matches(sourceString,pattern,System.Text.RegularExpressions.RegexOptions.IgnoreCase);
    foreach(Match result in results)
    {
    WL(result.Value);//输出
    }
      
    -----------------------------------------------
    msn:[email protected]
    请给我一个与您交流的机会
      

  3.   

    string strResoult = Regex.Replace("abc&..;ab c ",@"&\S*;","").Replace(" ","");
    System.Console.WriteLine("{0}",strResoult);