fork(2) download
  1. import java.util.*;
  2. import java.util.regex.*;
  3.  
  4. class Ideone
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. String regex = "\\s+|(?<=--)(?!--)|(?<!--)(?=--)";
  9. String string = "this is my--test string";
  10. System.out.println(Arrays.toString(string.split(regex)));
  11.  
  12. }
  13. }
Success #stdin #stdout 0.09s 48188KB
stdin
Standard input is empty
stdout
[this, is, my, --, test, string]