GoFrame gregex-基本使用

2022-04-11 14:58 更新

一个简单示例:

package main

import (
	"fmt"
	"github.com/gogf/gf/v2/text/gregex"
)

func main() {
	match, _ := gregex.MatchString(`(\w+).+\-\-\s*(.+)`, `GF is best! -- John`)
	fmt.Printf(`%s says "%s" is the one he loves!`, match[2], match[1])
}

执行后,输出结果为:

John says "GF" is the one he loves!


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号