Last active
December 19, 2015 19:09
-
-
Save chespinoza/6004341 to your computer and use it in GitHub Desktop.
Comparación entre funciones de busqueda de substrings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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