Created
September 15, 2014 17:23
-
-
Save ArcticEcho/f2abb1d4ca9ec96cee13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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