Categories

Archives

Regular Expression for inserting codes at the end of a function

This is a regular expression that i used to insert codes at the end of a function, the original code was created for actionscript 3, and you tweak it a little to match your language, that is if its a C-based language.
reg = “(“+funcName+”\\([\\s\\S]*?\\)[\\s\\S]*?{[\\s\\S]*?)(?=(})[\\s\\S]*?((protected override|private|public) function))”;
re = new RegExp(reg);
newCode = oldCode.replace(re, “$1 ” [...]