source : abcdeABCDE
replace : d,! -or- D!
result : abc!eABCDE
oReplace is a StringDictionary,
textboxes are all RichTextBoxen
I have tried with strings, stringbuilders, adding differenty ways, calling .ToString() on everyhing, adding to the SB as char array (.ToCharArray)!
Can you give the exact contents of the dictionary (keys and values)?
for (i = 0; i <= iLines; i++) {
sLine = this.txtReplace.Lines[i].ToString();
arrLine = sLine.Split(new char[]{','},2);
if (arrLine.GetUpperBound(0) != 1) {
this.txtResult.Text = "Bad replace line detected : " + sLine;
return;
} else {
if (oReplace.ContainsKey(arrLine[0])) {
this.txtResult.Text = "duplicate replace specified : " + arrLine[0];
return;
} else {
oReplace.Add(arrLine[0].ToString(),arrLine[1].ToString());
}
}
}
StringBuilder sb = new StringBuilder();sb.Append(this.txtSource.Text.ToString());
foreach (string sOrig in oReplace.Keys) {
sOld = sOrig.ToString();
sNew = oReplace[sOld].ToString();
this.txtResult.Text += "[" + sOrig + "][" + sNew + "]" + System.Environment.NewLine;
sb = sb.Replace(sOld.ToString(),sNew.ToString());
}this.txtResult.Text += sb.ToString();
0 comments:
Post a Comment