简体   繁体   中英

How to use regex to split set-cookie header

How would I use regex to split the set-cookie header into name and value:

Eg. test_cookie=Cookie+check; path=/; domain=.Site.com

name: test_cooke

value: Cookie+check; path=/; domain=Site.com

This would have the name in the first group, and value in the second

Dim r as Regex = new Regex("(.+?)=(.+)")
Dim cookie as string = "test_cookie=blah;bleh"
Dim name as string = r.Match(cookie).Groups(1).ToString()
Dim value as string = r.Match(cookie).Groups(2).ToString()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM