bryce
bryce

Reputation:

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

Upvotes: 0

Views: 2744

Answers (1)

Vinko Vrsalovic
Vinko Vrsalovic

Reputation: 340201

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()

Upvotes: 2

Related Questions