isJavaIdentifierPart

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

inline fun Char.isJavaIdentifierPart(): Boolean(source)
fun main() {
    val text = "abc_123$def 456"
    val identifierChars = text.filter { it.isJavaIdentifierPart() }
    println(identifierChars)   // prints: abc_123def456
}

Source