Advertisement
roronoa

replace emojis dans chaine ave customs

Apr 26th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. import java.math.*;
  4. class Solution {
  5.  
  6.     public static void main(String args[])
  7.     {
  8.         Scanner in = new Scanner(System.in);
  9.         int N = in.nextInt();
  10.         Map<String, String> hashMap = new HashMap<>();
  11.         String emojis[] = new String[N];
  12.         String regex = "(";
  13.         for (int i = 0; i < N; i++)
  14.         {
  15.             String EMOJI = in.next();
  16.             String CODE = in.next();
  17.             hashMap.put(EMOJI, CODE);
  18.             emojis[i] = EMOJI;
  19.         }
  20.         in.nextLine();
  21.         String S = in.nextLine();
  22.         for(String x : emojis)
  23.               S = S.replace(x,hashMap.get(x));
  24.         // pour que ça marche pour ":))))" -> ":)"
  25.         // dans la boucle for : je crée un regex += l'émoji et puis regex += "+" -> exemple regex = ":)+" ez
  26.         // puis S.replaceAll(regex, replacement); ez
  27.         System.out.println(S);  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement