REGEX FOR VALID JAVASCRIPT VARIABLE IN 1ST CHARACTER 04-06-2017, 03:44 PM
#1
Why am I so stupid? I need to test one character.
Regex has scared me for so long, I really don't know what I'm doing.
I'm writing a parser, so I'm only testing one character at a time.
the block of code I'm working with "knows" it's about to work on a variable. (or expects to)
For the first character in that variable I need to determine if it's $, _ or abc(a letter).
This, does not work. It doesn't match for $
Regex has scared me for so long, I really don't know what I'm doing.
I'm writing a parser, so I'm only testing one character at a time.
the block of code I'm working with "knows" it's about to work on a variable. (or expects to)
For the first character in that variable I need to determine if it's $, _ or abc(a letter).
Code:
if( /\w_$/g.test( _.getCurr() ) )
(This post was last modified: 04-06-2017, 03:46 PM by FractalBomb.)
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)