47 lines
841 B
Go
47 lines
841 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
chatline := "c-v Morretus Isayeki nv"
|
||
|
words := strings.Fields(chatline)
|
||
|
alerts := [...]string{"C-V6DQ", "1PF-BC", "EX-GBT", "Z-FET0"}
|
||
|
|
||
|
//var found bool
|
||
|
|
||
|
for _, word := range words {
|
||
|
for _, alert := range alerts {
|
||
|
|
||
|
if strings.EqualFold(word, alert) {
|
||
|
fmt.Println("Found: ", alert, "in", word)
|
||
|
}
|
||
|
|
||
|
// In the odd case somebody links "C-V6DQ*"
|
||
|
if len(word) < 6 {
|
||
|
alert = alert[:len(word)]
|
||
|
}
|
||
|
|
||
|
// In case of partials like "C-V"
|
||
|
if len(word) > 6 {
|
||
|
word = word[:5]
|
||
|
}
|
||
|
if strings.EqualFold(word, alert) {
|
||
|
fmt.Println("Found: ", alert, "in", word)
|
||
|
}
|
||
|
|
||
|
fmt.Println(word)
|
||
|
fmt.Println(alert)
|
||
|
fmt.Println("---")
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//fmt.Println(string(myString[:3]))
|
||
|
//fmt.Println("Dit")
|
||
|
//fmt.Println(strings.EqualFold(myString[:3], "Dit"))
|
||
|
|
||
|
}
|