Mayank Jain Mayank Jain - 9 months ago 195
Swift Question

case insensitive matching search in string array swift 3

In Swift 3, I want to create an array of matching string (case insensitive) from string array:-

I am using this code, but it is case sensitive,

let filteredArray = self.arrCountry.filter { $0.contains("india") }

how can I do this..
suppose I have a master string array called arrCountry, I want to create other array of all the string who has "india"(case insensitive) in it.

Can anyone help me out.

Hoa Hoa

You can try with localizedCaseInsensitiveContains

let filteredArray = self.arrCountry.filter { $0.localizedCaseInsensitiveContains("india") }