请问匹配 /*的正则表达式怎么写?
而匹配*/的呢?

解决方案 »

  1.   

    好像没对啊,
    我把他想这样的写,报错了。我加了个@,不报错了,但是没对。string left = “^\/\*$”;
    m = Regex.Match( s , left , RegexOptions.Compiled);
      

  2.   

    匹配 /*:^\/\*$
    匹配 */:^\*\/$string left = “^\/\*$”;//你换成英文的双引号string left = @"^\/\*$";
      

  3.   

    go to 
    http://www.regexlib.com/Search.aspxtype "comment" in the keyword textbox, click on the Search button, or use\/\*((?!\*\/).)*\*\/
      

  4.   

    xlkg_ss 谢谢,
    我自己碰运气碰出来了^-^,但是我不知道什么解释,private string left = "(/\\*)";
    private string right = "(\\*/)";match m ,q;
    m = Regex.Match( s , left , RegexOptions.Compiled);
    bLeft = m.Success;
    q = Regex.Match(s,right,RegexOptions.Compiled);
    bRight = q.Success;
      

  5.   

    to : usepc
    我试了不行,我是在.net用c#做的;
      

  6.   

    to : usepc
    能把你的测试代码给我 看看吗?
      

  7.   

    string ss=@"/*usepc*/";
    Regex re=new Regex(@"\057\052[a-z]*\052\057");
    MatchCollection mco=re.Matches(ss);
    foreach(Match ma in mco)
    {
    MessageBox.Show(ma.ToString());
    }