Grep and ignore white spaces


I've been working on a script to search for names of defines, and then grab the hex values for them and put them in the list. Once I have the list of names I'll attempt to search for "#define [name]" using -w to ensure exact match, and then awk '{ print $3 }' to grab the hex value.

However it works if the line is similar to

a.h:#define [name] 0x000

But it does NOT work if it is similar to

a.h:    #define [name] 0x000

How can I get around this? I have tried this

grep -nrw "\s*#define[[:space:]]*$p" . --include=*.h | awk '{ print $3 }'

I thought the \s* would ignore the leading whitespace before #define but it doesn't. Am I doing something wrong?

On linux this may work perfectly:

grep -Poinr "#define\s+\[.*?\K[0-9a-f]+x[0-9a-f]+" . --include=*.h