main.go 430 B

123456789101112131415161718192021222324
  1. package main
  2. import (
  3. "fmt"
  4. "regexp"
  5. )
  6. func main() {
  7. html := `aaaaaaaa
  8. <link rel="stylesheet" href="https://example.com/wp-content/themes/my-theme/style.css" type="text/css" media="all">
  9. aaaaaaaaaaa`
  10. re := regexp.MustCompile(`wp-content\/themes\/(.+?)\/`)
  11. result := re.FindStringSubmatch(html)
  12. if len(result) > 1 {
  13. themeName := result[1]
  14. fmt.Println(themeName)
  15. } else {
  16. fmt.Println("Theme name not found")
  17. }
  18. }