W3cubDocs

/Kotlin

isJavaIdentifierPart

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

Returns true if this character (Unicode code point) may be part of a Java identifier as other than the first character.

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

fun main(args: Array<String>) {
//sampleStart
val chars = listOf('a', '_', '1', 'β', '$', '+', ';')
val (javaIdentifierParts, notJavaIdentifierParts) = chars.partition { it.isJavaIdentifierPart() }
println(javaIdentifierParts) // [a, _, 1, β, $]
println(notJavaIdentifierParts) // [+, ;]
//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-part.html