TheBulgarianWolf

Text Filter

Mar 17th, 2021
586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1. using System;
  2.  
  3. namespace TextFilter
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             Console.Write("Enter banned word separated with \", \": ");
  10.             string[] banList = Console.ReadLine().Split(", ");
  11.             string text = Console.ReadLine();
  12.             foreach (string word in banList)
  13.             {
  14.                 int length = word.Length;
  15.                 string newOne = "";
  16.                 for(int i = 0; i < length; i++)
  17.                 {
  18.                     newOne += "*";
  19.                 }
  20.                 text = text.Replace(word, newOne);
  21.             }
  22.             Console.WriteLine(text);
  23.         }
  24.     }
  25. }
  26.  
Add Comment
Please, Sign In to add comment