Advertisement
IrinaIgnatova

Text Processing - Substring Remove

Jul 21st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. package com.company;
  2.  
  3.  
  4. import java.util.*;
  5. import java.util.stream.Collectors;
  6.  
  7. public class Main {
  8.  
  9.     public static void main(String[] args) {
  10.  
  11.         Scanner scanner = new Scanner(System.in);
  12.  
  13.         String wordToRemove = scanner.nextLine();
  14.         String text = scanner.nextLine();
  15.  
  16.         while (text.contains(wordToRemove)) {
  17.             text = text.replace(wordToRemove, "");
  18.         }
  19.  
  20.         System.out.println(text);
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement