isIdentifier¶
fun String?.isIdentifier(): Boolean
Checks if this string is a valid Kotlin identifier.
A regular identifier (without backticks) must:
-
Start with a letter (including Unicode letters) or underscore;
-
Contain only letters, digits, or underscores;
-
Not be a hard keyword.
Escaped identifiers (strings starting with a backtick) are also supported: the function returns true for strings such as `class` or `with spaces`.
The function performs only basic, platform-agnostic validation. Individual build targets may impose additional restrictions; for example, the JVM target also applies Java bytecode and Dalvik restrictions. See org.jetbrains.kotlin.resolve.jvm.checkers.DalvikIdentifierUtils.isValidDalvikCharacter.