MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / GetMatchNumber

Function GetMatchNumber

internal/util/util.go:282–298  ·  view source on GitHub ↗

accepts an input and splits it along a # if any. By default returns the full string and 1 as the number.

(input string)

Source from the content-addressed store, hash-verified

280// accepts an input and splits it along a # if any.
281// By default returns the full string and 1 as the number.
282func 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
300func FindMatchIn(searchName string, items ...string) (match string, closeMatch string) {
301

Callers 3

FindMatchInFunction · 0.92
TestGetMatchNumberFunction · 0.85
FindMatchInFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestGetMatchNumberFunction · 0.68