我要在VS2008IDE 中的查找里用正则表达
如:
public void Method(string path)
{
...
}我要把上面的以 "Method(" 开头和 ")" 间的字符去掉。
要怎么写正则表达式?

解决方案 »

  1.   

    Regex re = new Regex("Method\(.*?\)");
    re.Replace(re,"Method()"); 
      

  2.   

    Regex re = new Regex("Method *\(.*?\)"); 
    re.Replace(re,"Method()");用这个,上面那个没有去空格,判断不出 private void Method    (string str)这种格式.
      

  3.   

    为了挣你这100分,费了不少劲啊
    主要是语法跟一般的不同
    点击“查找内容”后面的三角符号,选择“完整字符列表”,可以看到语法
    具体在MSDN中的:
    ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.chs/dv_vsnav/html/718a617d-0e05-47e1-a218-9746971527f4.htm对于你具体的问题:
    查找:{Method:b\(}.*{\)}
    替换:\1\2
      

  4.   

    查找内容
    {public:b*void:b*Method\(}.*{\)}
    替换为
    \1\2
      

  5.   

    Find what: {Method\(}[^)]*{\)}
    Replace with: \1\2
      

  6.   

    查找内容 
    {:b*Method\(}.*{\)} 
    替换为 
    \1\2