通过正则表达式把给定字符串中的十六进制转换成十进制

    string str = this.textBox1.Text;
            Regex regex = new Regex("0[xX][0-9a-fA-F]{2,5}");
            MatchCollection mc = regex.Matches(str);
            foreach (Match m in mc)
            {
                str = str.Replace(m.Value, Convert.ToInt32(m.Value, 16) + "");
            }
            this.textBox1.Text = str;

 

posted @ 2014-06-30 17:41  自然去留  阅读(892)  评论(0编辑  收藏  举报