The following will match any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign "$", or the underscore character
/^[a-zA-Z\$_][a-zA-Z0-9]*/
The following is a example in Javascript
/^[a-zA-Z\$_][a-zA-Z0-9]*/
The following is a example in Javascript
alert(/^[a-zA-Z\$_][a-zA-Z0-9]*/.test("testVar"));
Comments
To simplify and correct the regex it can be written as
/^[\w\$][\w]*/
Since Firefox regex engine doesn't know Unicode \w is equivalent to [a-zA-Z0-9_]