How to split a string if any chracter is found in java

You can use String‘s methods replaceAll and split together here.

String one = "show ip interface brief | include 1234**\n Gi1/23.1234 YES manual up  up";
String[] tokens = one.replaceAll("[^\\n]+\\n\\s*", "").split("\\s+");


[Gi1/23.1234,, YES, manual, up, up]

Browse More Popular Posts

Leave a Comment