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.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. // your code goes here
  14. String s = "あ い&う え";
  15. Pattern p = Pattern.compile("&#(\\d{1,5}?);");
  16. Matcher m = p.matcher(s);
  17. String out = m.replaceAll(mr -> String.valueOf(Character.toChars(Integer.parseInt(mr.group(1)))));
  18.  
  19. Pattern p2 = Pattern.compile("\\s| ");
  20. Matcher m2 = p2.matcher(out);
  21. out = m2.replaceAll(mr -> " ");
  22. System.out.println(out);
  23. }
  24. }
Success #stdin #stdout 0.08s 33672KB
stdin
Standard input is empty
stdout
あ い&う え