You can use String
‘s methods replaceAll
and split
together here.
String one = "show ip interface brief | include 1234**\n Gi1/23.1234 xxx.225.xxx.106 YES manual up up";
String[] tokens = one.replaceAll("[^\\n]+\\n\\s*", "").split("\\s+");
System.out.println(Arrays.toString(tokens));
Output
[Gi1/23.1234, xxx.225.xxx.106, YES, manual, up, up]
solved How to split a string if any chracter is found in java