0

In this scenario the data I could have in my string may look like below but keep in mind the ids are dynamically generated so this isn't static and could be more than 2 if you haven't caught onto that.

ing:server blah blah, you. 2019,;:10-!gs.csd 1. id=value, otherid=value, pos=(22,22,33) 2. id=value2, otherid=value2, pos=(2g,2g,f) info other info info info info etc etc.

EDIT: How am I supposed to extract the individual values into strings afterwards from the string, the following does not work:

String valueString = "csd 1. id=value, otherid=value, pos=(22,22,33) ";

String value = valueString.Substring(valueString.IndexOf("otherid"), valueString.IndexOf(",") - valueString.IndexOf("otherid"));
Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Hesein Burg
  • 329
  • 3
  • 13

1 Answers1

3

You can do with Substring since you have already way of expecting when to start and when to end on your searching.

string result = x.Substring(x.IndexOf("csd"), (x.IndexOf("info ") - x.IndexOf("csd")));

I start searching on the start of the word "csd" and ends with the word "info " (with space), since there is also a word of info at the beginning of your string.

The result would be:

"csd 1. id=value, otherid=value, pos=(22,22,33) 2. id=value2, otherid=value2, pos=(24,21,33) "
Willy David Jr
  • 8,604
  • 6
  • 46
  • 57