StrFind returns the start and length of the rune at the specified position in the string
(s string, pos int)
| 17 | // StrFind returns the start and length of the rune at the |
| 18 | // specified position in the string |
| 19 | func StrFind(s string, pos int) (start, length int) { |
| 20 | |
| 21 | count := 0 |
| 22 | for index := range s { |
| 23 | if count == pos { |
| 24 | start = index |
| 25 | count++ |
| 26 | continue |
| 27 | } |
| 28 | if count == pos+1 { |
| 29 | length = index - start |
| 30 | break |
| 31 | } |
| 32 | count++ |
| 33 | } |
| 34 | if length == 0 { |
| 35 | length = len(s) - start |
| 36 | } |
| 37 | return start, length |
| 38 | } |
| 39 | |
| 40 | // StrRemove removes the rune from the specified string and position |
| 41 | func StrRemove(s string, col int) string { |