I have the following working regex that I tested in regex101
^function\s(\w+)\(\)\s{$
for the following test string
function hello() {
echo "Hello World"
}
function get_aws_credentials() {
echo "Getting AWS Credentials
}
My goal is to get all function names defined in that file and that's what my original regex does, but not in bash.
The problem is that it doesn't work in bash or zsh (I really only care about bash though).
I have researched it and saw some alternatives, like replacing the \w+ for [[:alnum:]], but that didn't work either.
This is how I'm testing it: cat utils.sh | grep "^function\s(\w+)\(\)\s{$"
Any idea of what I'm missing here?
Thanks!