ZZ2
小胜凭智 大胜靠德
/// <summary>
        
/// 检测输入字符串strInput是否在禁用字符串strConfigWords中存在,存在则过滤该输入值。
        
/// </summary>

        public string CheckRepWords(string strConfigWords,string strInput)
        
{
            
//创建strWords数组,以“|”号为分割符。
            string[] strWords = strConfigWords.Split(new char[] {'|'});
            
//依此读取数组中各个单元,并检测该字符串是否存在于以定义过滤词组strConfigWords中,
            
//strConfigWords一行内的格式为:“str1,str2”,若str1存在于输入内容strInput内,
            
//则将str1替换为str2。
            foreach(string strWord in strWords)
            
{
                
string[] strSplitWord = strWord.Split(new char[] {','});
                
if(strInput.IndexOf(strSplitWord[0])>=0)
                
{
                    strInput 
= strInput.Replace(strSplitWord[0],strSplitWord[1]);
                }

            }

            
return strInput;
        }
posted on 2005-07-31 12:55  Judy  阅读(3254)  评论(3)    收藏  举报