Valid Variable Name Format

A variable name is a name that is used to identify various entities in a program:

  • Variable names

  • Function argument names

  • Names of struct members

A variable name must match the following regular expression.

$[A-Za-z_][A-Za-z0-9_]*

The above regular expression means that an identifier has the following rules:

  • A variable name must start with a dollar sign ($)

  • After the dollar sign ($), it must contain a letter or underscore.

  • After the first letter or underscore, it can contain zero or more letters, numbers, or underscores.

Variable names are case-sensitive. For example, a variable name $myVar is treated as a different variable name than $MYVAR.