Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am having 3 three strings
Namely
String one;
String two;
String three;

Each stirng is 16 char length...And I would like to split each string by 2..means Each string totally will have 6 sub string...and I have to concatinate each split...pls Help me with the code
Posted
Comments
Naz_Firdouse 11-Jul-13 2:32am    
what is the purpose of splitting them into sub strings and then contatenate???
explain with an example
Chaitanya Pai 11-Jul-13 3:16am    
Mention the strings as an example so that question gets bit more clear...
Bharath Kumar Gorle 11-Jul-13 3:21am    
1234567890123456
1234567890123456
1234567890123456

three strings i want the op as
121212343434565656..........

var s1="1234567890123456";
var s2="1234567890123456";
var s3="1234567890123456";
var str="";
for(var i=0;i<7;i=i+2)
{

str = str + s1.substr(i, 2) + s2.substr(i, 2) + s3.substr(i, 2);

}

alert(str);
 
Share this answer
 
Javascript solution using regular Expression

var one = string.match(/.{1,2}/g);
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900