IsPascalCase reports whether s is in PascalCase format. PascalCase: starts with an uppercase letter and contains only letters and digits (no separators). Examples: "MyFeature", "ParseHTML", "Feat".
(s string)
| 88 | // PascalCase: starts with an uppercase letter and contains only letters and |
| 89 | // digits (no separators). Examples: "MyFeature", "ParseHTML", "Feat". |
| 90 | func IsPascalCase(s string) bool { |
| 91 | if s == "" { |
| 92 | return true |
| 93 | } |
| 94 | runes := []rune(s) |
| 95 | if !unicode.IsUpper(runes[0]) { |
| 96 | return false |
| 97 | } |
| 98 | for _, r := range runes { |
| 99 | if !unicode.IsLetter(r) && !unicode.IsDigit(r) { |
| 100 | return false |
| 101 | } |
| 102 | } |
| 103 | return true |
| 104 | } |
| 105 | |
| 106 | // IsSentenceCase reports whether s is in Sentence case format. |
| 107 | // Sentence case: first rune is uppercase; every subsequent letter is lowercase. |
no outgoing calls