extract variables from an expression using javascript regexp
Posted
by powerboy
on Stack Overflow
See other posts from Stack Overflow
or by powerboy
Published on 2010-04-09T19:29:25Z
Indexed on
2010/04/09
19:33 UTC
Read the original article
Hit count: 214
For example, here is a string representing an expression:
var str = 'total = sum(price * qty) * 1.09875';
I want to extract variables (i.e., 'total', 'price' and 'qty' but not 'sum' since 'sum' is a function name) from this expression. What is the regexp pattern in javascript? Variable name consists of letters, digits, or the underscore, beginning with letters or the underscore.
© Stack Overflow or respective owner