Skip to content

iskeyword

Test whether a string is a reserved keyword.

tf = iskeyword(str)
list = iskeyword

With a string argument, returns true if str is a reserved language keyword (if, for, function, end, etc.) — names that cannot be used as variables. Without arguments, returns a cell array of all keywords.

iskeyword('for') % 1
iskeyword('foo') % 0
iskeyword % {'break'; 'case'; 'classdef'; ...}
  • isvarname — Test whether a string is a valid variable name.