RGAlex

O4. Text Filter / Text Processing - Lab

Mar 11th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. package TextPlocessing.Lab;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class O4TextFilter {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String[] hideThis = scanner.nextLine().split(", ");
  9.         String input = scanner.next();
  10.         for (String word : hideThis) {
  11.             StringBuilder hide = new StringBuilder();
  12.             hide.append("*".repeat(word.length()));
  13.             input = input.replace(word, hide);
  14.         }
  15.         System.out.println(input);
  16.     }
  17. }
  18.  
  19.  
Advertisement
Add Comment
Please, Sign In to add comment