I am trying to get a Python regex to search through a .c file and get the function(s) inside it.
For example:
int blahblah(
struct _reent *ptr __attribute__((unused)),
const char *old,
const char *new
)
{
...
I would want to get blahblah as the function.
This regex doesn’t work for me, it keeps on giving me None: r"([a-zA-Z0-9]*)\s*\([^()]*\)\s*{"
(?<=(int\s)|(void\s)|(string\s)|(double\s)|(float\s)|(char\s)).*?(?=\s?\()http://regexr.com?3332t
This should work for what you want. Just keep adding types that you need to catch.
re.findall(r'(?<=(?<=int\s)|(?<=void\s)|(?<=string\s)|(?<=double\s)|(?<=float\s)|(?<=char\s)).*?(?=\s?\()', string)will work for python.