System.out.println(
Arrays.deepToString(
"abc<def>ghi".split("(?:<)|(?:>)")
)
);
This prints [abc, def, ghi]
, as if I had split on "<|>"
. I want it to print [abc, <def>, ghi]
. Is there a way to work some regex magic to accomplish what I want here?
Perhaps a simpler example:
System.out.println(
Arrays.deepToString(
"Hello! Oh my!! Good bye!!".split("(?:!+)")
)
);
This prints [Hello, Oh my, Good bye]
. I want it to print [Hello!, Oh my!!, Good bye!!]
.
`.