fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.regex.Matcher;
  4. import java.util.regex.Pattern;
  5.  
  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) {
  11. char[] arr=getDigits(new char[]{'1','R','Y','O','2','3','3' });
  12. for(int i=0;i<arr.length;i++){
  13. System.out.print(arr[i]);
  14. }
  15. }
  16.  
  17. public static char[] getDigits(char[] charArray) {
  18. Pattern p = Pattern.compile("-?\\d+");
  19. Matcher m = p.matcher(String.valueOf(charArray));
  20. String str=new String();
  21. while (m.find()) {
  22. str=str+m.group();
  23. }
  24. return str.toCharArray();
  25. }
  26. }
Success #stdin #stdout 0.08s 380224KB
stdin
Standard input is empty
stdout
1233