Skip to content

Instantly share code, notes, and snippets.

@chespinoza
Last active December 19, 2015 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chespinoza/6004341 to your computer and use it in GitHub Desktop.
Save chespinoza/6004341 to your computer and use it in GitHub Desktop.
Comparación entre funciones de busqueda de substrings
func GetId(s string) string {
i := strings.Index(s[0:], "ID=")
if i == -1 {
return ""
}
return s[i+3 : i+18]
}
var idRegex = regexp.MustCompile(`ID=(.*?)<`)
func GetIdRegex(s string) string {
results := idRegex.FindStringSubmatch(s)
if results == nil {
log.Printf("Patron ID no encontrado en:%s ", s)
return ""
}
return results[1]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment