正则表达式
应用背景:在VS中查找或替换选项中选择“使用”,并在下拉框中选择“正则表达式”后,下边命令即可正常使用。
作者楼主师傅midas---范
去掉分行连字符(替换为空)
\_\n:b*
------------------------
同一行多个语句的分行
\:
\n
-----------------------
过程替换
~((//)|(/\*).*)<{Sub:b+:i:b*\(.*\)[^\)]*}
\1\n{
~((//)|(/\*).*)<End:b+Sub
}
------------------------
函数替换
~((//)|(/\*).*)<{((Private)|(Public):b+)*}Function:b+{:i\(.*\)}:b*\n
//\0\n\1\2\n{\n
~((//)|(/\*).*)<{((Private)|(Public):b+)*}{Function:b+}{:i\(.*\)}:b*As:b+{:i}\n
//\0\n\1\2\4 \3\n{\n
End:b+Function
}
------------------------
简单变量定义替换
~((//)|(/\*))<{((Private)|(Public):b+)*}(Dim:b+)*{:i:b*(\(.*\))*}:b+As:b+{:i}
\1\3 \2/*\0*/
-------------------------
加分号
{^~(.*<(Sub)|(If)|(ElseIf)|(End)|(On)|(Select)|(Case)|(For)|(Next)|(Loop)|(Do)|(Else)|(\;)>)(:b*):i[^/]*(/[^/\*][^/]*)*}{((//)|(/*))*.*}
\1;\2
--------------------
If语句替换
~((//)|(/\*).*)<If{.*}Then:b*{:i[^/]*(/[^/\*]+)*}{((//)|(/*))*.*}
if(\1)\2;\3
~((//)|(/\*).*)<If{.*}Then
if(\1)\n{\n
ElseIf{.*}Then:b*{(:i[^/]*(/[^/\*]+)*)*}{((//)|(/*))*.*}
}\nelse if(\1)\n{\n
~((//)|(/\*)|(Case).*)<Else
}\nelse\n{\n
~((//)|(/\*).*)<End:b+If
}
------------------
Select Case语句替换
Select:b+Case:b+{.*}
switch(\1)\n{\n
Case:b+Else
break;\ndefault:
Case:b+{.*}
break;\ncase \1:
End:b+Select
}
--------------------
For Next语句替换
~((//)|(/\*).*)<For:b+{.*}\={.*}:b+To:b+{.*}Step{.*}
for(int \1 = \2; \1 <= \3; \1 += \4)//\0\n{\n
~((//)|(/\*).*)<For:b+{.*}\={.*}:b+To:b+{.*}~(Step)
for(int \1 = \2; \1 <= \3; ++\1)//\0\n{\n
~((//)|(/\*).*)<Next:b*\n
}//\0\n
~((//)|(/\*).*)<Next:b*{(:i[^\,]*)^1}\n
}//\0\n
~((//)|(/\*).*)<Next:b*{(:i[^\,]*)^2}\n
}\n}//\0\n
--------------------
Do Loop语句替换
~((//)|(/\*).*)<Do:b+Until:b+{[^/:b]+[^/]+(/[^/\*]+)*}{((//)|(/*))*.*}
while(!(\1))\2//\0\n{\n
~((//)|(/\*).*)<Do:b+While:b+{[^/:b]+[^/]+(/[^/\*]+)*}{((//)|(/*))*.*}
while(\1)\2//\0\n{\n
~((//)|(/\*).*)<Loop:b*\n
}\n
---------------------
数组下标替换
\(:b*{:a[^\>\<\=\(\)\{\}]*}\)
[\1]