fork download
  1. import java.util.*;
  2. import java.util.regex.*;
  3. class Ideone
  4. {
  5. public static void main (String[] args) throws java.lang.Exception
  6. {
  7. String p = "[!.?\n](?![!.?\n])";
  8. String p2 = "([!.?\n])(?!\\1)";
  9. String s = "I want it now!!!";
  10. System.out.println(Arrays.toString(s.split(p)));
  11. System.out.println(Arrays.toString(s.split(p2)));
  12. s = "Am I ok? Yeah, I'm fine!!!";
  13. System.out.println(Arrays.toString(s.split(p)));
  14. System.out.println(Arrays.toString(s.split(p2)));
  15. }
  16. }
Success #stdin #stdout 0.07s 33504KB
stdin
Standard input is empty
stdout
[I want it now!!]
[I want it now!!]
[Am I ok,  Yeah, I'm fine!!]
[Am I ok,  Yeah, I'm fine!!]