我想在字符串中的数字中添加一定数量的前导零.例如:
输入:"第1页",输出:"第001页"输入:"第12页",输出:"第012页"输入:"第123页",输出:"第123页"
使用Regex.Replace做到这一点的最佳方法是什么?
此刻我用这个但结果是001,0012,00123.
string sInput = "page 1";
sInput = Regex.Replace(sInput,@"\d+",@"00$&");
Run Code Online (Sandbox Code Playgroud)