Well it matches [
because of this statement:
[^a-fA-F_]
This will match anything that is not the letters A-F(any case) or an underscore
Why aren't you just matching the digits if that is what you want ?
For integers: \b\d+
For decimal numbers: \b\d+.\d+
For scientific: \b\d+e\d+
For hexadecimal: \b[\dA-Fa-F]+
Also as @Jan Dvorak mentions you can use word boundaries \b
, to make sure your matches begin at the beginning of a word (or number). See example here: http://regex101.com/r/kC6dK3