fork download
  1. using static System.Console;
  2. using System.Text;
  3. using System.Linq;
  4.  
  5. public class Program {
  6. public static void Main() {
  7. var texto = "(99) 9999-9999";
  8. WriteLine(texto.Replace("", '(', ')', '-', ' '));
  9. }
  10. }
  11.  
  12. public static class StringExt {
  13. public static string Replace(this string str, string newValue, params char[] chars) {
  14. var sb = new StringBuilder();
  15. foreach (var chr in str) {
  16. if (!chars.Contains(chr)) sb.Append(chr);
  17. else sb.Append(newValue);
  18. }
  19. return sb.ToString();
  20. }
  21. }
  22.  
  23. //https://pt.stackoverflow.com/q/98332/101
Success #stdin #stdout 0.03s 16892KB
stdin
Standard input is empty
stdout
9999999999