一个简单示例:

    1. package main
    2. import (
    3. "fmt"
    4. "github.com/gogf/gf/v2/text/gregex"
    5. )
    6. func main() {
    7. match, _ := gregex.MatchString(`(\w+).+\-\-\s*(.+)`, `GF is best! -- John`)
    8. fmt.Printf(`%s says "%s" is the one he loves!`, match[2], match[1])
    9. }

    执行后,输出结果为:

    1. John says "GF" is the one he loves!