I have a String
, in which I want to split Every x String.
I want to split every 7 String and it works !
Here is the code and the String.
Here is the String
:
ArrayList<String> arrayList=new ArrayList<String>();
String str="br_mgt>eth0>63 br_mgt>ath0>63 br0>br_mgt.100>63 br_data>eth0>63 br_data>ath0>63 br0>br_data.200>63 br_data>eth0>63 br_data>ath0>63 br0>br_data.200>75";
String[] theString=(str.split("(?<=\\.......)"));
System.out.println("First One : " + theString[0]);
System.out.println("Second one : " + theString[1]);
Output is :
First One : br_mgt>eth0>63 br_mgt>ath0>63 br0>br_mgt.100>63
Second one : br_data>eth0>63 br_data>ath0>63 br0>br_data.200>63
And It is true and what I wanted. I change the String to :
str="br0>br_mgt.333>63 br_mgt>eth0>63 br_mgt>ath0>63";
And the output is :
First One : br0>br_mgt.333>63
Second one : br_mgt>eth0>63 br_mgt>ath0>63
Why is that?