I've a string message that could be like
"TRX00 abcd 20150921 "
or like (n) times that string, I.e.
"TRX00 abcd 20150921 TRX00 abcd 20150921 TRX00 abcd 20150921 "
etc..
How can I split that string in (n) strings using "TRX" at the beginning of each substring like a delimiter?
I want to take the delimiter "TRX" in the substring.
I've done the following but it's doesn't work well..
string msg = "TRX00 abcd 20150921 TRX00 abcd 20150921 TRX00 abcd 20150921 ";
string[] _msg;
string pattern = "(TRX)";
string msg2 = "";
if(msg.Contains("TRX"))
{
_msg = Regex.Split(msg, pattern);
foreach (string ok in _msg)
{
msg2 = ok;
MessageBox.Show(msg2);
}
}
The expected result should be an array of substrings like:
{ "TRX00 abcd 20150921 ", "TRX00 abcd 20150921 ", etc.. }
" "that delimit the groups.