case insensitive matching search in string array swift 3

前端 未结 4 463
余生分开走
余生分开走 2021-01-07 17:21

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          


        
4条回答
  •  失恋的感觉
    2021-01-07 17:36

    Answer 2020:

    Even I put Chinese or Arabic, below test codes still returns TRUE

    let text = "total sdfs"
    let text1 = "Total 张"
    let text2 = "TOTAL لطيف"
    let text3 = "total :"
    let text4 = "ToTaL : "
    
    
    
    text.lowercased().contains("total")
    text1.lowercased().contains("张")
    text2.lowercased().contains("لطيف")
    text3.lowercased().contains("total")
    text4.lowercased().contains("total")
    
    
    text.localizedCaseInsensitiveContains("total")
    text1.localizedCaseInsensitiveContains("张")
    text2.localizedCaseInsensitiveContains("لطيف")
    text3.localizedCaseInsensitiveContains("total")
    text4.localizedCaseInsensitiveContains("total")
    

提交回复
热议问题