IsCamelCase reports whether s is in camelCase format. camelCase: starts with a lowercase letter and contains only letters and digits (no separators). Examples: "feat", "myFeature", "parseHTML".
(s string)
| 57 | // camelCase: starts with a lowercase letter and contains only letters and |
| 58 | // digits (no separators). Examples: "feat", "myFeature", "parseHTML". |
| 59 | func IsCamelCase(s string) bool { |
| 60 | if s == "" { |
| 61 | return true |
| 62 | } |
| 63 | runes := []rune(s) |
| 64 | if unicode.IsUpper(runes[0]) { |
| 65 | return false |
| 66 | } |
| 67 | for _, r := range runes { |
| 68 | if !unicode.IsLetter(r) && !unicode.IsDigit(r) { |
| 69 | return false |
| 70 | } |
| 71 | } |
| 72 | return true |
| 73 | } |
| 74 | |
| 75 | // IsKebabCase reports whether s is in kebab-case format. |
| 76 | // kebab-case: only lowercase letters, digits, and hyphens. |
no outgoing calls