Skip to content

isvarname

Test whether a string is a valid variable name.

tf = isvarname(str)

Returns true if str would be a valid variable identifier — starts with a letter, followed only by letters, digits, or underscores, AND is not a reserved keyword.

isvarname('myVar') % 1
isvarname('123abc') % 0 (starts with digit)
isvarname('for') % 0 (keyword)
  • iskeyword — Test whether a string is a reserved keyword.
  • exist — Check whether a name exists in the workspace, on disk, or as a built-in.