如何在Kotlin中检查字符串是否包含子字符串?

编程入门 行业动态 更新时间:2024-10-15 12:32:09
本文介绍了如何在Kotlin中检查字符串是否包含子字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

示例:

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

我要检查String1是否包含String2.

I want to perform a check that String1 contains String2 or not.

推荐答案

Kotlin具有stdlib包,可以对字符串执行某些扩展功能操作,可以选中此方法,它将检查字符串中的子字符串,可以忽略通过传递true/false值的情况.引用此链接

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中检查字符串是否包含子字符串?

本文发布于:2023-11-29 16:10:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1646901.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   如何在   Kotlin

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!