Example:

String1 = "AbBaCca";
String2 = "bac";

我想判断String1是否包含String2.

推荐答案

Kotlin has stdlib package to perform certain extension function operation over the string, you can check this method it will check the substring in a string, you can ignore the case by passing true/false value. Refer this link

"AbBaCca".contains("bac", ignoreCase = true)

Kotlin相关问答推荐

API迁移到Spring Boot 3后,Spring Security无法工作

在Mapstruct中重用@映射定义

关键字';在When Kotlin When-语句中

Groovy Gradle文件的Kotlin类似功能

S使用MAP和ElseThrow的习惯用法是什么?

在 map 中查找键与在 kotlin 中查找 firstOrNull

Kotlin supervisorScope 即使包裹在 try catch 中也会失败

使用 kotlin 流删除 map 中具有某些相似性的值

在 kotlin 原始字符串中转义三重引号

判断 Kotlin 变量是否为函数

Kotlin Path.useLines { } - 如何不获取 IOException("Stream closed")?

Kotlin - 协程未按预期执行

第二个协程永远不会执行

从字符串列表构建字符串

Kotlin:内部类如何访问在外部类中声明为参数的变量?

致命错误 LifecycleOwners 必须在 registerForActivityResult 开始之前调用 register

无法为 retrofit2.Call 调用无参数构造函数

API 26 上未显示 Android 通知

目前不支持 Gradle 项目的自动库版本更新.请手动更新您的 build.gradle

Kotlin中默认导入哪些包/函数?