Just for the sake of variety:
private string s1 = "[fconsender]Username (11:00 AM):[/fconsender] Hi Good Afternoon!";
private string s2 = "[fconreceiver]AnotherUser (11:02 AM):[/fconreceiver] Yea! How are you ?";
private string getInnerText(string theText)
{
return (theText.Contains("sender"))
? theText.Substring(12, theText.IndexOf('[', 1) - 12)
: theText.Substring(14, theText.IndexOf('[', 1) - 14);
}
private void Test_getInnerText()
{
string s3 = getInnerText(s1);
string s4 = getInnerText(s2);
Console.WriteLine("{0},\r\n{1}", s3, s4);
}
Yes, I know the dangers of using "hard-coded" indexes; if you don't, forget this code :)