public static void Main() 
{
string s = "1 12 3 5";
s = Regex.Replace(s,@"/d+",new MatchEvaluator(CorrectString),RegexOptions.CompiledRegexOptions.IgnoreCase);
Console.WriteLine(s);
Console.ReadLine();
}
PRivate static string CorrectString(Match match) 
{
string matchValue = match.Value;
if(matchValue.Length == 1)
matchValue = "0" + matchValue;
return matchValue;
}
public static void Main() 
{
string s = "1 12 3 5";
s = Regex.Replace(s,@"(/d+)(?#这个是注释)","0$1",RegexOptions.CompiledRegexOptions.IgnoreCase);
Console.WriteLine(s);
Console.ReadLine();
} 新闻热点
疑难解答