package main
import (
"fmt"
"regexp"
)
func delete_empty (s []string) []string {
var r []string
for _, str := range s {
if str != "" {
r = append(r, str)
}
}
return r
}
func main(){
text := "red 1 green 3 blue"
result := regexp.MustCompile("red|green|blue").Split(text, -1)
fmt.Printf("%q\n",result)
fmt.Printf("%q\n",delete_empty(result))
}
cGFja2FnZSBtYWluCmltcG9ydCAoCgkiZm10IgoJInJlZ2V4cCIKKQoKZnVuYyBkZWxldGVfZW1wdHkgKHMgW11zdHJpbmcpIFtdc3RyaW5nIHsKICAgIHZhciByIFtdc3RyaW5nCiAgICBmb3IgXywgc3RyIDo9IHJhbmdlIHMgewogICAgICAgIGlmIHN0ciAhPSAiIiB7CiAgICAgICAgICAgIHIgPSBhcHBlbmQociwgc3RyKQogICAgICAgIH0KICAgIH0KICAgIHJldHVybiByCn0KCmZ1bmMgbWFpbigpewoJdGV4dCA6PSAicmVkIDEgZ3JlZW4gMyBibHVlIgoJcmVzdWx0IDo9IHJlZ2V4cC5NdXN0Q29tcGlsZSgicmVkfGdyZWVufGJsdWUiKS5TcGxpdCh0ZXh0LCAtMSkKCWZtdC5QcmludGYoIiVxXG4iLHJlc3VsdCkKCWZtdC5QcmludGYoIiVxXG4iLGRlbGV0ZV9lbXB0eShyZXN1bHQpKQp9