Skip to content
Advertisement

Bash command to check if the variable name is valid

JavaScript

and so on the variable name can have only letters , numbers (but not on the beginning),.. and like all the rules for java…

Is there any function that I can use ? I do not want to reinvent the wheel…

Advertisement

Answer

Match the variable name against a regex, like this:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement