numbers - How can I have all the integers in a string that has a combination of alphanumeric characters using RegEx -


for example have: 1|2|3,4|5|6,7|8|10;

how can output this:

a: 1 2 3 b: 4 5 6 c: 7 8 10 

and how can this:

array = {1,2,3} array b = {4,5,6} array c = {7,8,10} 

var reg = /(\d+)\|(\d+)\|(\d+)[,;]/g; var str = "1|2|3,4|5|6,7|8|10;"; var index = 0; str.replace(reg,function myfun(g,g1,g2,g3){                     var ch = string.fromcharcode(65 + (index++));                     return ch+": "+g1+" "+g2+" "+g3+"\n";                 }); 

the second case should update myfun return string:

"array "+ch+" = {"+g1+","+g2+","+g3+"}\n"; 

Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -