java - Split String Every X String does not work -


i have string, in want split every x string. want split every 7 string , works ! here code , string. here 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 1 : " + thestring[0]);         system.out.println("second 1 : " + thestring[1]); 

output :

first 1 : br_mgt>eth0>63 br_mgt>ath0>63 br0>br_mgt.100>63 second 1 :  br_data>eth0>63 br_data>ath0>63 br0>br_data.200>63 

and true , wanted. change string :

str="br0>br_mgt.333>63 br_mgt>eth0>63 br_mgt>ath0>63"; 

and output :

first 1 : br0>br_mgt.333>63 second 1 :  br_mgt>eth0>63 br_mgt>ath0>63 

why that?

    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";     string[] array = str.split("(?<=\\g[^\\>]*\\>[^\\>]*\\>[^\\>]*\\>[^\\>]*\\>[^\\>]*\\>[^\\>]*\\>[^\\>]*)\\s+");     for(string s : array){         system.out.println(s);     } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -