Skip to content

Instantly share code, notes, and snippets.

@oisdk
Last active August 29, 2015 14:24
Show Gist options
  • Save oisdk/3ac0e2e6361de0e174c9 to your computer and use it in GitHub Desktop.
Save oisdk/3ac0e2e6361de0e174c9 to your computer and use it in GitHub Desktop.
import Foundation
extension String.UnicodeScalarView.Generator {
mutating func hasUpper() -> Bool {
return next().map {
NSCharacterSet
.uppercaseLetterCharacterSet()
.longCharacterIsMember(UInt32($0))
|| hasUpper()
} ?? false
}
}
extension String {
func hasUpper() -> Bool {
var g = unicodeScalars.generate()
return g.hasUpper()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment