looping thru string
Hi I have a string like so:
firstname: jason | jeff^lastname: smith |^mname: robert | kevin
I am trying to split on the "^" and then split on the "|" and then check if there is a value in the second index of the "|" split.
this is what i have:
foreach (string s in Regex.Split(messageBody, "^", RegexOptions.IgnoreCase))
{
for (int t = 0; t < s.Length; t++)
{
string[] temp = s .Split(new Char[] { '|' }, 2);
if (temp[1].ToString().Length > 0)
mBody += s + "\r\n";
}
}
the result should be:
firstname: jason | jeff
mname: robert | kevin
and ignor the: lastname: smith | because ther is no value after the "|"
any suggestions? thanks
|