I need to distinguish between variable names and variable names in some expressions that I am trying to parse. Variable names begin with a colon, can have (but not begin with) numbers, and have underscores. Thus, valid variable names are:
:x :_x :x2 :alpha_x // etc
Then I need to highlight other words in an expression that does not start with a colon. So in the following expression:
:result = median(:x,:y,:z)
Variables will be: result ,: x ,: y and: z, while another non-variable word will be median.
My regex for choosing variable names (this works):
:[a-zA-Z_]{1}[a-zA-Z0-9_]*
But I can’t understand how to get invariable words. My regex for this is:
(?<!:)([a-zA-Z_]{1}[a-zA-Z0-9_]*)
The problem is that the match only excludes the first character after: like this:

source share