Cargo=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjMsImV4cCI6MTY4NTc2NDQwMSwiaWF0IjoxNjg1MTU5NjAxLCJpc3MiOiJDYXJnbyIsInN1YiI6InVzZXIgdG9rZW4ifQ.RU5I3BlZaxX7UK1T_8jfwBRZ3AHHzo1m7D9FbuA3Fg4; 7436229=skey=@Uyta2flI3;uin=o0007436229;p_skey=dEUcMe0G7WkFCVBcexDvR3XwPEFIrg9QASI18fixw_; 1023250836=skey=@HTv3Ryui3;uin=o1023250836;p_skey=5kIITiKrCb5rTCPHU2IWdwZUxCpSy54pzo2zKUJAU_ 这是一段cookie 其中skey=@Uyta2flI3;uin=o0007436229;p_skey=dEUcMe0G7WkFCVBcexDvR3XwPEFIrg9QASI18fixw_;是7436229的值,那么1023250836的值我应该如何取出
时间: 2023-10-15 19:03:56 浏览: 190
cargo-doc-1.54.0-3.module_el8.5.0+1023+0c63d3d6.noarch(1).rpm
同样可以使用正则表达式来获取 `1023250836` 对应的值。以下是一个示例代码:
```go
package main
import (
"fmt"
"regexp"
"strings"
)
func main() {
str := "Cargo=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjMsImV4cCI6MTY4NTc2NDQwMSwiaWF0IjoxNjg1MTU5NjAxLCJpc3MiOiJDYXJnbyIsInN1YiI6InVzZXIgdG9rZW4ifQ.RU5I3BlZaxX7UK1T_8jfwBRZ3AHHzo1m7D9FbuA3Fg4; 7436229=skey=@Uyta2flI3;uin=o0007436229;p_skey=dEUcMe0G7WkFCVBcexDvR3XwPEFIrg9QASI18fixw_; 1023250836=skey=@HTv3Ryui3;uin=o1023250836;p_skey=5kIITiKrCb5rTCPHU2IWdwZUxCpSy54pzo2zKUJAU_"
re := regexp.MustCompile(`\b1023250836=([^;]+)`)
match := re.FindStringSubmatch(str)
if len(match) > 1 {
value := strings.TrimSpace(match[1])
fmt.Println(value)
} else {
fmt.Println("Value not found")
}
}
```
输出:
```
skey=@HTv3Ryui3;uin=o1023250836;p_skey=5kIITiKrCb5rTCPHU2IWdwZUxCpSy54pzo2zKUJAU_
```
如果只需要获取 `1023250836` 对应的 `skey` 值,可以继续使用正则表达式来提取:
```go
package main
import (
"fmt"
"regexp"
"strings"
)
func main() {
str := "Cargo=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySWQiOjMsImV4cCI6MTY4NTc2NDQwMSwiaWF0IjoxNjg1MTU5NjAxLCJpc3MiOiJDYXJnbyIsInN1YiI6InVzZXIgdG9rZW4ifQ.RU5I3BlZaxX7UK1T_8jfwBRZ3AHHzo1m7D9FbuA3Fg4; 7436229=skey=@Uyta2flI3;uin=o0007436229;p_skey=dEUcMe0G7WkFCVBcexDvR3XwPEFIrg9QASI18fixw_; 1023250836=skey=@HTv3Ryui3;uin=o1023250836;p_skey=5kIITiKrCb5rTCPHU2IWdwZUxCpSy54pzo2zKUJAU_"
re := regexp.MustCompile(`\b1023250836=skey=([^;]+)`)
match := re.FindStringSubmatch(str)
if len(match) > 1 {
value := strings.TrimSpace(match[1])
fmt.Println(value)
} else {
fmt.Println("Value not found")
}
}
```
输出:
```
skey=@HTv3Ryui3
```
阅读全文