查找并替换中文字符

将页面翻译成其它语言时,需要将页面上的中文字符检索出来

 public string FindContents(string str)
        { 
            string x = @"[\u4E00-\u9FFF]+";
            MatchCollection Matches = Regex.Matches(str, x, RegexOptions.IgnoreCase);
            StringBuilder sb = new StringBuilder();
            foreach (Match NextMatch in Matches)
            {
                str= str.Replace(NextMatch.Value, Html.LangString( NextMatch.Value)); 
            } 
            return str;
        }

  

posted @ 2018-06-28 17:10  个人天使  阅读(215)  评论(0编辑  收藏  举报