0
string mystring = "-p \"C:\\Users\\mplususer\\Documents\\SharpDevelop Projects\\test\\test\\bin\\Debug\\test.exe\" -t False -r TestRun"

i have to extract from mystring whatever in front of command -r here is "Testrun"

string[] value = mystring .Split(new string[] { "\"-r " }, StringSplitOptions.None);
                if (value.Length != 0)
                {
                    runConfig = value[1].Replace("\"", "");
                }
ND's
  • 2,155
  • 6
  • 38
  • 59

1 Answers1

2

I'd use this String.Split version:

string[] value = mystring.Split(new string[] {" -r " }, 2, StringSplitOptions.None);
string runConfig = value.Last().Split()[0]; 

The second Split is just for the case that there are other parameters after the -r possible.

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939