本帖最后由 idwma 于 2023-5-10 11:33 编辑
回复 12# 小白龙
是这样吗- $s1 -replace '(?<a>\s*)(private|public|static|async|(?<b>(string|void|int\?|\(string, int\)|IEnumerable<int>|Task<string>)\s*)|\s*)*(?<c>FUN1\s*\(\s*\)\s*\{(?:[^{}]+|\{(?<DEPTH>)|\}(?<-DEPTH>))*?(?(DEPTH)(?!))\})','${a}public static ${b}${c}'
复制代码 再试试这样- $s1 -replace '(?<a>\s*)(private|public|static|async|(?<b>(\b\S+|\([^()]+\))\s*)|\s*)*(?<c>FUN1\s*\(\s*\)\s*\{(?:[^{}]+|\{(?<DEPTH>)|\}(?<-DEPTH>))*?(?(DEPTH)(?!))\})','${a}public static ${b}${c}'
复制代码
|