「Kotlin」split()で文字列をカンマで区切るサンプル

2021年7月13日

書式
対象文字列.split(“,")
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
fun main() {
val cft = "study,skill,in,arkgame,.com"
val ptn = ","
val resLst = cft.split(ptn)
println("カンマで区切るリスト")
for (res in resLst) {
print(res +" ")
}
}
fun main() { val cft = "study,skill,in,arkgame,.com" val ptn = "," val resLst = cft.split(ptn) println("カンマで区切るリスト") for (res in resLst) { print(res +" ") } }
fun main() {

    val cft = "study,skill,in,arkgame,.com"
      
      val ptn = ","
    val resLst = cft.split(ptn)
      
      println("カンマで区切るリスト")
      
    for (res in resLst) {
        print(res +" ") 
      }
}

実行結果
>kotlin arkgame.jar
カンマで区切るリスト
study skill in arkgame .com

Kotlin

Posted by arkgame