Reputation: 394
I am new to android studio and kotlin. I need to find a way to check if a string contains a char, which is, in this case, "/" I want to form a piece of code in the following manner:
if (string input contains a character "/") = true {
<code>
}
else{
<code>
}
Please tell me how to do this, and if possible, give me the code I'll need to specify as the condition.
Upvotes: 0
Views: 3241
Reputation: 162
You can use contains, like this:
val a = "hello/"
val b = a.contains("/")
When the string has the character will return true.
Upvotes: 2