don't know exactly what you want to extract, sometimes regular expressions is not the perfect tool, you'd better off use yacc/lexbut see chapter 9 (.NET, downloadable pdf file) of Mastering Regular Expressions, 2nd Edition By Jeffrey E. F. Friedl
http://www.oreilly.com/catalog/regex2/there is an example of nested "("'s

解决方案 »

  1.   

    TO: saucer(思归)
        我也不是非得用正则表达式。    我的目的是解释上述函数脚本,并计算结果。我最先想到的是用正则表达式解析出函数和它的参数,如果参数是数字则存储,如果是另一个函数则进行递归操作。    我现在的问题是判断下一个参数是数值还是函数,并把它取出,这应该说是一个算法问题,而我以为可以利用正则表达式简化
      

  2.   

    不太明白你的意思是什么,如果你要定义自己的句法,那么建议你自己写parser,如
    果你需要动态地evaluate,你可以用CodeDom什么的,动态产生Assembly,参考Runtime C# Expression Evaluator
    http://www.codeproject.com/csharp/runtime_eval.aspDynamic Code Generation and Code Compilation
    http://www.codeproject.com/dotnet/dynacodgen.aspReflection Emit
    http://www.ondotnet.com/pub/a/dotnet/excerpt/prog_csharp_ch18/index.html?page=6#refl_emit
      

  3.   

    我正在自己写Parser,希望有些实例来模仿,主要是算法