fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.*;
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println(replaceEmoji("{a} {b} {c}"));
  13. System.out.println(replaceEmoji("abc"));
  14. }
  15. public static String replaceEmoji(String string) {
  16. if (string == null || string.isEmpty()) return string;
  17. Matcher m = Pattern.compile("\\{(\\w+)}").matcher(string);
  18. StringBuilder sb = new StringBuilder();
  19. while (m.find()) {
  20. m.appendReplacement(
  21. sb,
  22. "<<" + m.group(1) + ">>"
  23. //Emojis.getEmoji(m.group(1))
  24. );
  25. }
  26. m.appendTail(sb);
  27.  
  28. return sb.toString();
  29. }
  30.  
  31. }
Success #stdin #stdout 0.12s 52784KB
stdin
Standard input is empty
stdout
<<a>> <<b>> <<c>>
abc