java - Regex to find variables and ignore methods -
i'm trying write regex finds variables (and variables, ignoring methods completely) in given piece of javascript code. actual code (the 1 executes regex) written in java. for now, i've got this: matcher matcher=pattern.compile(".*?([a-z]+\\w*?).*?").matcher(string); while(matcher.find()) { system.out.println(matcher.group(1)); } so, when value of "string" variable*func()*20 printout is: variable func which not want. simple negation of ( won't do, because makes regex catch unnecessary characters or cuts them off, still functions captured. now, have following code: matcher matcher=pattern.compile(".*?(([a-z]+\\w*)(\\(?)).*?").matcher(formula); while(matcher.find()) { if(matcher.group(3).isempty()) { system.out.println(matcher.group(2)); } } it works, printout correct, don't additional check. ideas? please? edit (2011-04-12): thank answers. there questions, why need that. , right, in case of bigger,...