Advertisement
elena1234

TextFilter*

Nov 12th, 2020 (edited)
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3.  
  4. namespace TextFilter
  5. {
  6.     class MainClass
  7.     {
  8.         public static void Main(string[] args)
  9.         {
  10.             string[] bannedWords = Console.ReadLine().Split(", ",StringSplitOptions.RemoveEmptyEntries);
  11.             string text = Console.ReadLine();
  12.  
  13.             foreach (var word in bannedWords)
  14.             {
  15.                 while (text.Contains(word))
  16.                 {
  17.                     text = text.Replace(word, new string('*', word.Length));
  18.                 }
  19.             }
  20.  
  21.             Console.WriteLine(text);
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement