Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class ChangeToUpperCase {
- public static void main(String[] args){
- Scanner s = new Scanner(System.in);
- String text = s.nextLine();
- Matcher m = Pattern.compile("(?<=<upcase>)[^<>]*(?=</upcase)").matcher(text);
- while (m.find()){
- text = text.replace(m.group(), m.group().toUpperCase()).replace("<upcase>", "").replace("</upcase>", "");
- }
- System.out.println(text);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement