tags:

views:

362

answers:

1

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

+1  A: 

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()
Vinko Vrsalovic
but that would give you back the path and domain of cookie x, as if it were another cookie.
DevelopingChris
That's what I understood from the question, "name: test_cooke" "value: Cookie+check; path=/; domain=Site.com"
Vinko Vrsalovic
Works. Thank You