Consider:
object HelloWorld {
def main(args: Array[String]): Unit = {
val s:String = "AbcD"
println(s.contains("ABCD"))
println(s.contains("AbcD"))
}
}
Output:
false
true
I need the result to be true in both cases regardless of the case. Is it possible?
If you really need contains
use
s.toLowerCase.contains("abcd")
But most likely you are looking for
s.equalsIgnoreCase("abcd")
with Regex
println(s.matches("(?i:.*" + "ABCD" + ".*)"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With