cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Cazzie
Level 2

Variables containing "$..$"

I am prompting for a password and assign it to the variable $PASS$. I then use that variable down the road to set the account of a Windows service. My problem is if the password that is entered starts and ends with a dollar sign, the $PASS$ variable equates to a null string. I have tried all combinations of escaping the variable but nothing works. I've tried:

"$PASS$"
'$PASS$'
$DOLLAR$PASS$DOLLAR$
\$PASS\$
/$PASS/$
etc.

Does anyone have any ideas? At first I thought this would rarely come up but two of my passwords that were given to me by two different people follow the convention of $...$.
Labels (1)
0 Kudos
(2) Replies
amitaks2
Level 5

I think $DOLLAR$PASS$DOLLAR$ should work.
0 Kudos
yundtrichard
Level 2

Javascript is very flexible in regards to checking for "null" values. I guess you're actually looking for empty strings, in that case this simpler code should work:

if(!pass || !cpass || !email || !cemail || !user){

Which will check for empty strings (""), null, undefined, fals, and the numbers 0 and NaN

Please note that if you are specifically checking numbers then it's a common error to drop 0 through this method and num! == 0 takes precedence (num! == -1 or ~ num (hacky code also checks - 1)) for functions that return -1, for example indexOf)

hill climb racing

0 Kudos