Tel Tel - 1 year ago 35
Swift Question

How can I create a list of words that contains upper case letters in swift?

I would like to generate a list of words form a given string where each listed word contains at least an upper case letter.

Having a string like this one:

let str: String = "Apple watchOS 3 USA release date and feature rumours."

I would like to get an array like this:

var list: [String] = ["Apple", "watchOS", "USA"]

What is the best way to do this?

Answer Source
var list = str.componentsSeparatedByString(" ").filter{ $0.lowercaseString != $0 }