How to split to string Java

I guess something like this should work. But i don’t really understood why you would do something like that

String wait =("<z1>0176543210010005160D2001000</z1>
               <z2>S4P6W7M522SC3OXX55K3NN77666N34M2</z2>");

String string1 = wait.split("</z1><z2>")[0].replace("<z1>","");
String string2 = wait.split("</z1><z2>")[1].replace("</z2>","");
System.out.println(string1);
System.out.println(string2);

Leave a Comment