fork download
  1. using System;
  2. using System.Text;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. string[] errorChars = new string[]
  9. {
  10. "!",
  11. "}",
  12. "{",
  13. "'",
  14. };
  15. string fTextSearch = "{testing[for]; my' homies}";
  16. StringBuilder sb = new StringBuilder();
  17.  
  18. string[] splitString = fTextSearch.Split(errorChars, StringSplitOptions.None);
  19.  
  20. int numNewCharactersAdded = 0;
  21. foreach( string itm in splitString)
  22. {
  23. sb.Append(itm); //append string
  24. if (fTextSearch.Length > (sb.Length - numNewCharactersAdded))
  25. {
  26. sb.Append(fTextSearch[sb.Length - numNewCharactersAdded]); //append splitting character
  27. sb.Append(fTextSearch[sb.Length - numNewCharactersAdded - 1]); //append it again
  28. numNewCharactersAdded ++;
  29. }
  30. }
  31.  
  32. string myBetterString = sb.ToString();
  33.  
  34. Console.Write( myBetterString);
  35. }
  36. }
Success #stdin #stdout 0.04s 37096KB
stdin
Standard input is empty
stdout
{{testing[for]; my'' homies}}