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. String input = "1 dog \r\n 2 cat";
  13. String[] output = input.split("(?<=\\R)");
  14.  
  15. for(int i=0; i < output.length; i++)
  16. {
  17. System.out.println("----------------------------------------");
  18. System.out.println("Match: " + output[i]);
  19.  
  20. for(int j=0; j < output[i].length(); j++) {
  21. System.out.println("ASCII: " + output[i].charAt(j) + ": " + (int)output[i].charAt(j) );
  22. }
  23. }
  24.  
  25. }
  26. }
Success #stdin #stdout 0.05s 2184192KB
stdin
Standard input is empty
stdout
----------------------------------------
Match: 1 dog 

ASCII: 1:  49
ASCII:  :  32
ASCII: d:  100
ASCII: o:  111
ASCII: g:  103
ASCII:  :  32
ASCII: 
:  13
ASCII: 
:  10
----------------------------------------
Match:  2 cat
ASCII:  :  32
ASCII: 2:  50
ASCII:  :  32
ASCII: c:  99
ASCII: a:  97
ASCII: t:  116