Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created November 1, 2020 00:07
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 parzibyte/3c0655843788b9a65d9dba87785c5b30 to your computer and use it in GitHub Desktop.
Save parzibyte/3c0655843788b9a65d9dba87785c5b30 to your computer and use it in GitHub Desktop.
package main
/*
https://parzibyte.me/blog
*/
import (
"fmt"
"regexp"
)
func main() {
subdominios := [...]string{
"https://ejemplo.parzibyte.me",
"https://sublime-pos.parzibyte.me",
"https://juegos.parzibyte.me",
"https://admin.parzibyte.me",
"https://hola.parzibyte.me",
"http://hola.parzibyte.me",
"http://www.parzibyte.me",
"https://www.parzibyte.me",
"https://hola.parzibyte.com",
"acerca-de.parzibyte.me",
}
expresionRegular := regexp.MustCompile(`^https?:\/\/([\w-]+\.)?parzibyte\.me$`)
subdominioPrueba := "https://blog.parzibyte.me"
if expresionRegular.Match([]byte(subdominioPrueba)) {
fmt.Println("Coincide")
} else {
fmt.Println("NO coincide")
}
for _, subdominio := range subdominios {
coincide := expresionRegular.Match([]byte(subdominio))
fmt.Printf("¿'%s' coincide? %t\n", subdominio, coincide)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment