I need to do the following:
static string[] pats = { "?", "?", "?", "?", "?", "?", "?", "?", "?", "?" ,"è", "è", "à", "à", "ì", "ì", "?", "?", "?", "?" };
static string[] repl = { "a", "A", "a", "A", "a", "A", "o", "O", "o", "O", "e", "E", "a", "A", "i", "I", "o", "O", "i", "I" };
static int i = pats.Length;
int j;
// function for the replacement(s)
public string DoRepl(string Inp) {
string tmp = Inp;
for( j = 0; j < i; j++ ) {
tmp = Regex.Replace(tmp,pats[j],repl[j]);
}
return tmp.ToString();
}
/* Main flow processes about 45000 lines of input */
Each line has 6 elements that go through DoRepl. Approximately 300,000 function calls. Each does 20 Regex.Replace, totalling ~6 million replaces.
Is there any more elegant way to do this in fewer passes?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…