fork download
  1. package main
  2.  
  3. import (
  4. "regexp"
  5. "fmt"
  6. )
  7.  
  8. func main() {
  9. s := "runcmd -name abcd xyz -descr abc def"
  10. re1 := regexp.MustCompile(`^([^-]+ -name).*?(-descr\b.*)$`)
  11. result := re1.FindStringSubmatch(s)
  12. fmt.Printf(result[1])
  13. fmt.Printf("\n")
  14. fmt.Printf(result[2])
  15. }
Success #stdin #stdout 0s 3284KB
stdin
Standard input is empty
stdout
runcmd -name
-descr abc def