2024-04-28 15:27:01
用C#语言的
using System;
using System.Text.RegularExpressions;
namespace MatchApplication{
class MatchProgram{
static void Main(string[] args){
string str="var c= 2*(function(a)-function1(function2(a+b*2),3))+4*5;";
string pattern = @"(function|function1)\([^()]*(((?'Open'\()[^()]*)+((?'-Open'\))[^()]*)+)*(?(Open)(?!))\)";
MatchCollection mc=Regex.Matches(str, pattern);
foreach (Match m in mc){
Console.WriteLine(m.Groups[0]);
}
}
}
}
2024-04-28 16:14:16