I am working on making a regex to recognize a function for my new programming language's syntax highlighting file for vim. I cannot for the life of me understand how to make it match this though.
it would need to match all functions in an example like this:
int addFive() {
}
addFive()
int addFive()
{
}
int value = addFive ()
addFive(int number)
void sum ( string hello )
etc...
but cannot figure it out.
here is what I managed to figure out: [a-zA-Z]*()$
I don't know the all of the syntax you're trying to match, but something like this might work:
[a-zA-Z]+?\s*?\(.*?\)[a-zA-Z]+?matches alphabet characters, if you want numbers as well you could do[a-zA-Z0-9]+?\s*?matches possible whitespace between the function name and the parentheses\(matches the first parenthesis.*?matches any characters inside the parentheses\)matches the last parenthesistest it out: https://regex101.com/r/L2guif/1