Advertisement
Guest User

Untitled

a guest
May 10th, 2015
637
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5. using System.Threading.Tasks;
  6.  
  7. namespace TextFilter_4
  8. {
  9.     class TextFilter_4
  10.     {
  11.         static void Main(string[] args)
  12.         {            
  13.             string input = Console.ReadLine();
  14.             string[] bannedWords = Regex.Split(input, @"[, ]+");
  15.             string text = Console.ReadLine();
  16.  
  17.             foreach (var p in bannedWords)
  18.             {
  19.             Regex word = new Regex("\\b" + p.ToString() + "\\b");
  20.                 text = word.Replace(text, delegate(Match match)
  21.                 {
  22.                     string forRemoving = match.ToString();
  23.                     return new string('*', forRemoving.Length);
  24.                 });
  25.             }
  26.             Console.WriteLine(text);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement