日期:2014-05-20  浏览次数:20929 次

数字,字母格式转化
请问如何将1,2,或A,,B,,,
转换为01,01,,,0A,,0B


谢谢

------解决方案--------------------
MessageBox.Show( "A ".PadLeft(2, "0 "))
------解决方案--------------------
string s = "A ";
s = '0 ' + s;
------解决方案--------------------
string a = "A ";
string b = a.PadLeft(2, "0 ");
//b : 0A
------解决方案--------------------
"A ".PadLeft(2, "0 ")
就是将字符串不足两位时左补 "0 "
------解决方案--------------------
//用正则可以吗?

using System.Text.RegularExpressions;

Text = Regex.Replace( "1,2,A,,B,,, ", @ "(,{0,1})([a-zA-Z0-9],) ", @ "${1}0$2 ");

//01,02,0A,,0B,,,