Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fund05Noem_2017_Part2;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class AnonymousVox {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- String line = reader.readLine();
- String placeholder = reader.readLine();
- placeholder = placeholder.substring(1, placeholder.length() - 1);
- String[] placeholders = placeholder.split("\\}\\{");
- Pattern pattern = Pattern.compile("([A-Za-z]+)(.*)(\\1)");
- Matcher matcher = pattern.matcher(line);
- for (int i = 0; i < placeholders.length; i++) {
- String replace = placeholders[i];
- if (matcher.find()) {
- line = line.replace(matcher.group(2), replace);
- }
- }
- System.out.println(line);
- }
- }
Add Comment
Please, Sign In to add comment