Two things:
var smilies = new OrderedDictionary
{
{@">:(", "smile_angryx24"}, // Put this one first
{@":(", "smile_sadx24"},
};
foreach (string smiley in smilies.Keys)
{
var re = new Regex(@"(?<!(=""))" + Regex.Escape(smiley) + @"(?!(""))");
// Second should be a negative lookahead ^^
if (re.IsMatch(incomingtext))
{
string m2 = re.Replace(incomingtext, "<img src=\"/Content/themes/mavi/img/custom/smiles/" + smilies[smiley] + ".png\" alt=\"" + smiley + "\"/>");
incomingtext = m2;
}
}
Using a negative look behind where there was supposed to be a lookahead was what caused the regex to fail when you swapped the angry and sad smileys, because the smiley characters aren't using "
at all.