Regex for JavaScript variable identifiers

Discussion in 'Javascript' started by Mark Szlazak, Aug 21, 2003.

  1. Mark Szlazak

    Mark Szlazak Guest

    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!
    Mark Szlazak, Aug 21, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. valentin tihomirov

    Advantages of denying keywords as identifiers

    valentin tihomirov, Dec 17, 2004, in forum: VHDL
    Replies:
    8
    Views:
    505
    Mike Treseler
    Dec 28, 2004
  2. Replies:
    1
    Views:
    340
    Roedy Green
    Apr 22, 2008
  3. Replies:
    3
    Views:
    734
    Reedick, Andrew
    Jul 1, 2008
  4. Replies:
    4
    Views:
    171
    Paul Cooper
    Mar 24, 2006
  5. Nnaemeka David

    limits between identifiers and variable names

    Nnaemeka David, Oct 7, 2013, in forum: C Programming
    Replies:
    5
    Views:
    146
    James Kuyper
    Oct 7, 2013
Loading...

Share This Page