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[] words = "abc3xab".split("((?<=[0-9]+x)|(?=[0-9]+x))");
  13. System.out.println(Arrays.toString(words));
  14. String[] words1 = "abc3xxab".split("((?<=[0-9]+x)|(?=[0-9]+x))");
  15. System.out.println(Arrays.toString(words1));
  16. String[] words2 = "abc34xxab".split("((?<=[0-9]+x)|(?=[0-9]+x))");
  17. System.out.println(Arrays.toString(words2));
  18. String[] words3 = "abc100ab".split("((?<=[0-9]+x)|(?=[0-9]+x))");
  19. System.out.println(Arrays.toString(words3));
  20. String[] words4 = "abc10axb".split("((?<=[0-9]+x)|(?=[0-9]+x))");
  21. System.out.println(Arrays.toString(words4));
  22.  
  23. }
  24. }
Success #stdin #stdout 0.12s 321600KB
stdin
Standard input is empty
stdout
[abc, 3x, ab]
[abc, 3x, xab]
[abc, 3, 4x, xab]
[abc100ab]
[abc10axb]