Ben Bozorg
Ben Bozorg

Reputation: 184

getting Array-like query string from url parameters list C#

I am struggling extracting values from the followin

https://hlapservice0i/Web/api/Purchaselist/Creditor?
 filter[logic]=and&
 filter[filters][0][value]=John Doe &
 filter[filters][0][field]=customFilter&
 filter[filters][0][operator]=contains&
 filter[filters][0][ignoreCase]=true

I'm trying to get that John Doe value stored in filter[filters][0][value]

It is a simple MVC controller.

Upvotes: 0

Views: 146

Answers (1)

Sateesh Pagolu
Sateesh Pagolu

Reputation: 9606

You could do like this..

Live Demo here

var match = Regex.Match(input,@"(?<=filter\[filters\]\[0\]\[value\]=).*?(?=&)");

match.Value will have value you are after, which is John Doe

Explained:

?<= forces match to start after first occurrence of filter[filters][0][value].

?= forces match to end before following character, which is, in this case, &

Upvotes: 1

Related Questions