The following is some code that searches an existing string for two other
strings (start marker and end marker), then gets only the required piece out
of the middle.
const string MODULE_LABEL = "/module";
// Get the command line parameters/arguments
ls_Argument = Environment.GetCommandLineArgs();
ls_Command_Line = String.Join(" ", ls_Argument);
ls_Command_Line = ls_Command_Line.Trim();
// Find the beginning of the /module parameter value
li_Position_Start = ls_Command_Line.IndexOf(MODULE_LABEL);
if (li_Position_Start == -1)
return -2011;
li_Position_Start += MODULE_LABEL.Length;
// Find end of the /module parameter value
li_Position_End = ls_Command_Line.IndexOf("/", li_Position_Start + 1);
if (li_Position_End == -1)
{
// use remainder of string
li_Position_End = ls_Command_Line.Length;
}
else
{
li_Position_End --;
}
// Get Module parameter value
ls_Parameter_Value = ls_Command_Line.Substring(li_Position_Start,
li_Position_End - li_Position_Start);
ls_Parameter_Value = ls_Parameter_Value.Trim();