Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public static KeyValuePair<string, string> GetLastChatMessage(string html)
{
var startIndex = html.LastIndexOf("username owner", StringComparison.Ordinal);
startIndex = html.IndexOf(">", startIndex, StringComparison.Ordinal) + 1;
// Get username.
var username = html.Substring(startIndex, (html.IndexOf(">", startIndex + 1, StringComparison.Ordinal) - startIndex) - 5);
// Get message.
startIndex = html.LastIndexOf("<DIV class=content>", startIndex, StringComparison.Ordinal) + 19;
var message = html.Substring(startIndex, html.IndexOf("</DIV>", startIndex, StringComparison.Ordinal) - startIndex);
return new KeyValuePair<string, string>(username, message);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.