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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -