splash/Sources/Splash/Extensions/Strings/String+PrefixChecking.swift

26 lines
521 B
Swift
Raw Normal View History

2018-08-24 18:42:07 +02:00
/**
* Splash
* Copyright (c) John Sundell 2018
* MIT license - see LICENSE.md
*/
import Foundation
internal extension String {
var isCapitalized: Bool {
guard let firstCharacter = first.map(String.init) else {
return false
}
return firstCharacter != firstCharacter.lowercased()
}
var startsWithLetter: Bool {
guard let firstCharacter = first else {
return false
}
return CharacterSet.letters.contains(firstCharacter)
}
}