fork download
  1. import java.util.Arrays;
  2.  
  3. public class Main
  4. {
  5. public static void main(String[] args) throws Exception
  6. {
  7. String string = "How dare you! You have lost him two days ago:'(";
  8. String regex = " |(?<! |\\p{Punct})(?=\\p{Punct})|(?<=\\p{Punct})(?!\\p{Punct})";
  9. System.out.println(Arrays.asList(string.split(regex)));
  10. }
  11. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
[How, dare, you, !, You, have, lost, him, two, days, ago, :'(]