高浪匹配字符以获得子字符串

https://<some strings>appid=c5f1b8ee7da1&source=<some strings>&path=<some strings>

我想匹配并得到appid=&c5f1b8ee7da1


蝴蝶刀刀
浏览 72回答 1
1回答

郎朗坤

您可以使用该包来解析 URL。net/urlpackage mainimport (&nbsp; &nbsp; "fmt"&nbsp; &nbsp; "net/url")func main() {&nbsp; &nbsp; s := "https://example.com?appid=c5f1b8ee7da1&source=asd&path=123"&nbsp; &nbsp; u, err := url.Parse(s)&nbsp; &nbsp; if err != nil {&nbsp; &nbsp; &nbsp; &nbsp; panic(err)&nbsp; &nbsp; }&nbsp; &nbsp; params, err := url.ParseQuery(u.RawQuery)&nbsp; &nbsp; if err != nil {&nbsp; &nbsp; &nbsp; &nbsp; panic(err)&nbsp; &nbsp; }&nbsp; &nbsp; fmt.Println(params.Get("appid"))}开始游戏: https://goplay.space/#JTEq0wAlW1U
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go