Advertisement
BojidarDosev

Text filtering

Mar 18th, 2025
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         String[] banned = scan.nextLine().split(", ");
  8.         String text = scan.nextLine();
  9.  
  10.         for (String word : banned) {
  11.             String replacement = "*".repeat(word.length());
  12.             text = text.replace(word, replacement);
  13.         }
  14.  
  15.         System.out.println(text);
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement