Can you use non-capturing regex in String split?

Posted by polygenelubricants on Stack Overflow See other posts from Stack Overflow or by polygenelubricants
Published on 2010-03-09T04:16:52Z Indexed on 2010/03/09 4:21 UTC
Read the original article Hit count: 174

Filed under:
|
|
|
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?

© Stack Overflow or respective owner

Related posts about java

Related posts about regex