I am currently writing a Python script that will search an entire .c or .h file and find all the function definitions so I can then make some slight edits. To find all of the function definitions I am trying to use Regular Expressions.
What I currently have is:
"r'\w+?\s+?\w+?\s*?\(.*?\)[\n\s]*?{"
The problem with this logic is that it currently will accept certain if statements in some cases. For example:
else
if(//herpderp){}
It does this because that \s includes \n. I feel that I wouldn't have this issue if I had my expression only look for spaces instead of any whitespace, but I can't test my theory out as it seems there is no \(insert letter here) for just a simple space.
So there is the problem. If you have any advice on how to fix my regular expression, or if there is a better way of writing the script in general please let me know.