-1

How can I get and copy to table specified strings from response(I Think that it is same as getting from any text)?

I mean that for example I am getting response like:

PSEUDO CODE:

"blablabla... rank:1, name:string1, blablabla, rank:2, name:string2... "

I would like to get and copy string1,string2,string3,..., to table. How can I do IT?

crthompson
  • 15,653
  • 6
  • 58
  • 80
user3014282
  • 209
  • 2
  • 12

3 Answers3

1

You probably need (I'm not sure, question is not very clever) to parse JSON into a C# collection of some type (if the response is JSON) and then you can access data easily.

To parse JSON, see this question: How can I parse JSON with C#?

Community
  • 1
  • 1
Francesco Belladonna
  • 11,361
  • 12
  • 77
  • 147
0

Assuming your result is really not JSON (see my comment to @Fire-Dragon-DoL), I would recommen parsing this with a regex:

  • use "name:([^,])" to capture a single string
  • Use either the combination IList-ToArray()-Join(",") or a StringBuilder to concatenate
Eugen Rieck
  • 64,175
  • 10
  • 70
  • 92
0

You can use Regex to match the names and get the values in an array.

string input = "blablabla... rank:1, name:string1, blablabla, rank:2, name:string2";

string[] result = Regex.Matches(input, @"name:(?<Name>[^,]+)")
    .OfType<Match>()
    .Select(o => o.Groups["Name"].Value)
    .ToArray();
BrunoLM
  • 97,872
  • 84
  • 296
  • 452