1
0
mirror of https://github.com/alice-lg/alice-lg.git synced 2024-05-11 05:55:03 +00:00
2017-06-30 12:05:46 +02:00

33 lines
489 B
Go

package main
// Some helper functions
import (
"regexp"
"strings"
)
/*
Case Insensitive Contains
*/
func ContainsCi(s, substr string) bool {
return strings.Contains(
strings.ToLower(s),
strings.ToLower(substr),
)
}
/*
Check if something could be a prefix
*/
func MaybePrefix(s string) bool {
s = strings.ToLower(s)
// Test using regex
matches := regexp.MustCompile(`([a-f0-9/]+[\.:]?)+`).FindAllStringIndex(s, -1)
if len(matches) == 1 {
return true
}
return false
}