mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Handle connsecutive capital letters in camelCaseToWords function
This commit is contained in:
parent
b0e3960fba
commit
de9bf4d52e
1 changed files with 5 additions and 5 deletions
|
|
@ -61,11 +61,11 @@ extension String {
|
|||
}
|
||||
|
||||
func camelCaseToWords() -> String {
|
||||
return unicodeScalars.dropFirst().reduce(String(prefix(1))) {
|
||||
return CharacterSet.uppercaseLetters.contains($1)
|
||||
? $0 + " " + String($1)
|
||||
: $0 + String($1)
|
||||
}
|
||||
return self
|
||||
.replacingOccurrences(of: "([a-z])([A-Z](?=[A-Z])[a-z]*)", with: "$1 $2", options: .regularExpression)
|
||||
.replacingOccurrences(of: "([A-Z])([A-Z][a-z])", with: "$1 $2", options: .regularExpression)
|
||||
.replacingOccurrences(of: "([a-z])([A-Z][a-z])", with: "$1 $2", options: .regularExpression)
|
||||
.replacingOccurrences(of: "([a-z])([A-Z][a-z])", with: "$1 $2", options: .regularExpression)
|
||||
}
|
||||
|
||||
var length: Int {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue