Advertisement
veronikaaa86

03. Substring

Nov 10th, 2021
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. package textProcessing;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P03Substring {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. String toRemove = scanner.nextLine();
  10. String text = scanner.nextLine();
  11.  
  12. int index = text.indexOf(toRemove);
  13.  
  14. while (index != -1) {
  15. text = text.replace(toRemove, "");
  16. index = text.indexOf(toRemove);
  17. }
  18.  
  19. System.out.println(text);
  20. }
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement