I\'m working on a regular expression to recognize variable declarations in C and I have got this.
[a-zA-Z_][a-zA-Z0-9]*
Is there any bette
This will eliminate return and typedef false flags. It is capable of capturing the return type and variable name, and supports pointers and arrays. It also eliminates commented code further reducing false flags in addition to detecting typedef variables.
^\s*(?!return |typedef )((\w+\s*\*?\s+)+)+(\w+)(\[\w*\])?(\s*=|;)