0

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.

3
  • Do you want to parse this string and get only filter[filters][0][value] value? Commented Feb 16, 2017 at 5:37
  • try Spliting string after IndexOf('?') on '&' and then the resulting elements on '=' to separate values from keys Commented Feb 16, 2017 at 7:40
  • @DarkKnight Yes, that is the only value I need. Commented Feb 16, 2017 at 21:42

1 Answer 1

1

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, &

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your help and effort :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.