I want to compare 2 strings like if 1 string contain some part of other then it will true for example
if "test" == "es"
{
}
I want true in above case
Note - strings maybe of any length
I want to compare 2 strings like if 1 string contain some part of other then it will true for example
if "test" == "es"
{
}
I want true in above case
Note - strings maybe of any length
Don't use NSString
in Swift. Use String
(which is also the default when you create Strings).
Anyway, contains()
is what you're looking for.
if "test".contains("es") {
// this will run
}
if "test".contains("es") {
//...
}