accepts an input and splits it along a # if any. By default returns the full string and 1 as the number.
(input string)
| 280 | // accepts an input and splits it along a # if any. |
| 281 | // By default returns the full string and 1 as the number. |
| 282 | func GetMatchNumber(input string) (string, int) { |
| 283 | // Clean up the input |
| 284 | input = strings.TrimSpace(strings.ToLower(input)) |
| 285 | // See if the item has a # and if so grab the left as the name, and the right as the number |
| 286 | if !strings.Contains(input, "#") { |
| 287 | return input, 1 |
| 288 | } |
| 289 | |
| 290 | parts := strings.Split(input, "#") |
| 291 | input = parts[0] |
| 292 | inputNumber, _ := strconv.Atoi(strings.Join(parts[1:], "#")) |
| 293 | if inputNumber < 1 { |
| 294 | inputNumber = 1 |
| 295 | } |
| 296 | |
| 297 | return input, inputNumber |
| 298 | } |
| 299 | |
| 300 | func FindMatchIn(searchName string, items ...string) (match string, closeMatch string) { |
| 301 |
no outgoing calls