|
では、ループも再帰も三項演算子も使わないパターンで。。。
using System;
using System.Text.RegularExpressions;
class Program {
static string c1(Match m) {
return m.Value.Replace(m.Value[0],(char)(m.Value[0]+0x20));
}
static string c2(Match m) {
return m.Value.Replace(m.Value[0],(char)(0x69-m.Value[0]));
}
public static void Main() {
string s = "Abc012_59F_#012Gh";
Regex r1=new Regex("[A-Z]"); MatchEvaluator m1=new MatchEvaluator(c1);
Regex r2=new Regex("[0-9]"); MatchEvaluator m2=new MatchEvaluator(c2);
Console.WriteLine("[{0}]\n[{1}]",s,r2.Replace(r1.Replace(s.Substring(0,s.IndexOf('#')),m1),m2)+s.Substring(s.IndexOf('#')));
}
}
# なんかココの課題になってるなぁ...^^::
|