//: Playground - noun: a place where people can play import Foundation var str = "Hello, playground" str.capitalizedString // 字符串中所有单词首字母大写, 不改变str本身的值 str str += ", hello, rinpe chan" str.capitalizedString str.uppercaseString // 全大写 str.lowercaseString // 全小写 // trim var str2 = " hi ?!@" str2.stringByTrimmingCharactersInSet(NSCharacterSet(charactersInString: " !?@")) // 切除字符串中的字符 // split var str3 = "welcome to Shantou" str3.componentsSeparatedByString(" ") // 分割 // 分割更复杂的字符串 var str4 = "rinpe, bobo! how-are-u?" str4.componentsSeparatedByCharactersInSet(NSCharacterSet(charactersInString: " !-?")) // join var str5 = "-" ["1", "2", "3"].joinWithSeparator(str5)