Gocnak/Botnak — pull request #43 by fragmer (2014-08-07 08:04:26+00:00)
Title: Possible regex fix for emotes with inequality symbols

Twitch performs HTML escaping on the symbols first, turning "<" and ">" into "<" and ">".
All symbols are then escaped for JavaScript's regex syntax: "\>\;" and "\<\;".
We then have to add another layer of escaping for Java's own regex (for replaceAll): "\\>\\;" and "\\<\\;".
Finally, last layer of escaping for Java's string literals: "\\\\>\\\\;" and "\\\\<\\\\;".

The replacement strings also need escaping (once for regex, and once more for Java string literals), since "<" and ">" characters have special meaning in Java regex (as part of lookbehind construct). So they become "\\<" and "\\>".