Think of a string like this:
public function test(data)
{
    if (1 == 2)
    {
        alert("Wtf?");
    }
    switch (data)
    {
        case 'test':
            alert("Test");
        break;
    }
}
I need to parse that string, so that I have the body (content) of that function.
I already got my reg exp working so that I have the contents of the function, but when there is an ending }. The regular expression stops and the content will look like this:
if (1 == 2)
{
   alert("Wtf?");
I really hope somebody can help me out..
this is my Reg Exp for splitting this string:
var test = classContent.replace(/(?:(private|public)\s*)function\s*([a-zA-Z0-9_]+)\s*\(([a-zA-Z0-9_\,\s]*)\s*\)\s*{([^}]+)\}/gi, function(a, b, c, d, e) {
    classMethods[c] = {
        visibility : b.trim(),
        params : d.trim(),
        content : e.trim()
    };
});