我怎么能在科特林拆分字符串

How could i split the string in kotlin

   private fun handleDynamicLink() {
    Firebase.dynamicLinks
        .getDynamicLink(intent)
        .addOnSuccessListener { pendingDynamicLinkData ->
            val deepLink: Uri?
                if (pendingDynamicLinkData != null) {
                    deepLink = pendingDynamicLinkData.link

                  deepLink?.getQueryParameter("inviteCode")?.let{connecttest(it)}

生成价值

的inviteCode字符串
https://example.com/?inviteCode=myuser?myToken%3DeyJ0eXAiOiJKV1QiLCJ

我想把它拆分成字符串

inviteCode =myuser; & myToken = eyJ0eXAiOiJKV1QiLCJ;

想在此处使用这些值:

private fun connecttest (inviteCode: String, myToken: String) {
    MeetingUtils.starttest(
        this,
        inviteCode,
        myToken
 ) // Start Test

}

如何在 Kotlin 中执行此操作?

我只会使用多个替换和拆分调用

如果这是Url

https://example.com/?inviteCode=myuser?myToken%3DeyJ0eXAiOiJKV1QiLCJ

那你可以打电话

val splitUrl =url.replace("https://example.com/?inviteCode=","").split("?")
val user = splitUrl[0]
val token = splitUrl[1].replace("myToken%","")

编辑:替换部分仅用于删除那些部分,用空字符串替换它们。