16 lines
344 B
Go
16 lines
344 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
)
|
|
|
|
// 匹配 http/https 协议链接,不单独捕获协议字段
|
|
var urlRegex = regexp.MustCompile(`(?:http|https)://\w+\.\w+\.\w+`)
|
|
|
|
func main() {
|
|
text := "站点:https://www.miaoall.cn 镜像:http://www.miaoall.cn"
|
|
res := urlRegex.FindAllString(text, -1)
|
|
fmt.Println("匹配链接:", res)
|
|
}
|