W3cubDocs

/Kotlin

isJavaIdentifierStart

Platform and version requirements: JVM (1.0)
fun Char.isJavaIdentifierStart(): Boolean

Returns true if this character is permissible as the first character in a Java identifier.

import kotlin.test.*
import java.util.*

fun main(args: Array<String>) {
//sampleStart
val chars = listOf('a', '_', 'β', '$', '1', '+', ';')
val (javaIdentifierStarts, notJavaIdentifierStarts) = chars.partition { it.isJavaIdentifierStart() }
println(javaIdentifierStarts) // [a, _, β, $]
println(notJavaIdentifierStarts) // [1, +, ;]
//sampleEnd
}

© 2010–2020 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.text/is-java-identifier-start.html