f



Regex for JavaScript variable identifiers

I'm attempting to make a regex that will match variable identifier names
without matching keywords or object properties, and matching function
argument names is optional.

This attempt seems to work but there has been little QA.

rx =
/(?:^|[=,;])\s*([a-zA-Z_$][\w$]*)\s*(?=\=)|\bvar\s*([a-zA-Z_$][\w$]*)\s*
(?=[=,;\n])/g;

If anyone can spot potential problems and/or how to improve them, please
let me know. Thanks in advance.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
0
Mark
8/21/2003 1:12:50 AM
comp.lang.javascript 38370 articles. 0 followers. javascript4 (1315) is leader. Post Follow

0 Replies
3339 Views

Similar Articles

[PageSpeed] 53

Reply: