Advertisement
shady_obeyd

17.ChangeToUppercase

Dec 6th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4. import java.util.regex.Matcher;
  5. import java.util.regex.Pattern;
  6.  
  7. public class ChangeToUpperCase {
  8.     public static void main(String[] args){
  9.         Scanner s = new Scanner(System.in);
  10.  
  11.         String text = s.nextLine();
  12.  
  13.         Matcher m = Pattern.compile("(?<=<upcase>)[^<>]*(?=</upcase)").matcher(text);
  14.  
  15.         while (m.find()){
  16.             text = text.replace(m.group(), m.group().toUpperCase()).replace("<upcase>", "").replace("</upcase>", "");
  17.         }
  18.         System.out.println(text);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement