fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  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. cal("xyzoneyctwothreefourvone");
  13. }
  14.  
  15. //We need to convert xyzoneyctwothreefourvone to numbers : 1,234,1
  16.  
  17. public static void cal(String s){
  18.  
  19. HashMap<String, String> map= new HashMap<String, String>();
  20. map.put("zero", "0");
  21. map.put("one", "1");
  22. map.put("two", "2");
  23. map.put("three", "3");
  24. map.put("four", "4");
  25.  
  26. for(Map.Entry<String, String> entry : map.entrySet()) {
  27. s = s.replaceAll(entry.getKey(), entry.getValue());
  28. }
  29.  
  30. s = s.replaceAll("[a-z]", "+");
  31. System.out.println(s.toString());
  32. }
  33. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
+++1++234+1