Commit dd72ba20dc678c7adba4abf00959e778489f3ff9

Authored by Marko Tikvić
1 parent 836cccf887
Exists in master

CharAt

Showing 1 changed file with 20 additions and 0 deletions   Show diff stats
... ... @@ -81,3 +81,23 @@ func StringSliceContains(slice []string, s string) bool {
81 81 }
82 82 return false
83 83 }
  84 +
  85 +func StringAt(s string, index int) string {
  86 + if len(s)-1 < index || index < 0 {
  87 + return ""
  88 + }
  89 +
  90 + return string(s[index])
  91 +}
  92 +
  93 +func SplitStringAfterN(s string, n, count int) (parts []string) {
  94 + rem := s
  95 + i := 0
  96 + for len(rem) > n && (i < count || count < 0) {
  97 + parts = append(parts, rem[0:n])
  98 + rem = rem[n:]
  99 + i++
  100 + }
  101 + parts = append(parts, rem)
  102 + return parts
  103 +}
... ...