2
我有一個問題orderedDictionary
和Regex
。我如何可以定義文本的問題,但我會盡力解釋...OrderedDictionary和Regex
這是我的代碼:
var smilies = new OrderedDictionary
{
{@":(", "smile_sadx24"},
{@">:(", "smile_angryx24"},
};
foreach (string smiley in smilies.Keys)
{
var re = new Regex(@"(?<!(=""))" + Regex.Escape(smiley) + @"(?<!(""))");
if (re.IsMatch(incomingtext))
{
string m2 = re.Replace(incomingtext, "<img src=\"/Content/themes/mavi/img/custom/smiles/" + smilies[smiley] + ".png\" alt=\"" + smiley + "\"/>");
incomingtext = m2;
}
}
當我試圖處理>:(
然後返回smile_sadx24
不smile_angryx24
.. 。
因爲它趕上:(
首先...
我怎樣才能解決這個問題?
試着把憤怒的笑臉先放在字典中嗎? – Jerry
已經嘗試過了。沒有影響:/ –