这是我迄今为止(用于测试目的):
let string = "The quick BroWn fOX jumpS Over tHe lazY DOg" for chr in string { if isupper(String(chr)) { print(String(chr).lowercaseString) continue } print(chr) }
如何测试大小写字符?
您可以随时查看小写表示与当前值的不同;
原文链接:https://www.f2er.com/swift/320425.htmllet string = "The quick BroWn fOX jumpS Over tHe lazY DOg" var output = "" for chr in string { var str = String(chr) if str.lowercaseString != str { output += str } } print(output) >>> TBWOXSOHYDO