I am trying to extract all the functions I have in a file using REGEX. Here's a standard file example:
int main()
{
printf("hello to all the good people");
printf("hello to all the good people %d ", GetLastError());
for(int i =0; i<15; i++)
{
if(i == 5)
{
switch(i)
{
case 0:
break;
}
}
}
}
In the meantime, I have only succeeded in capturing functions using the following REGEX:
regex = re.findall('\w+\s*?[(].*[)]', _content) #'\w+\s*?[(]*[)]'
for i in regex:
print i
My problems are:
- How can I tell him to ignore things like FOR or SWITCH?
- How do I tell him to find an internal function inside an externally as an example:
printf ("%s", get_string());
How do I make it not to relate to
()
that are between quotes as()
that aren't between quotes (so if i have line:printf("hello to j. (and rona) %s", get_family_name());
he will know to extract:foo name: parameters: printf "hello to j. (and rona) %s", get_family_name() get_family_name none