In Javascript, I want to extract array from a string. The string is
var str = "abc (24 314 83 383)(-256)sa 0 (24 314) 1"
I want priority to be the text in parentheses then other text separated by white space. So for the above example, the result should to be:
result[0] = "abc"
result[1] = "24 314 83 383"
result[2] = "-256"
result[3] = "sa"
result[4] = "0"
result[5] = "24 314"
result[6] = "1"
I tried
var pattern = /(.*?)[\s|\)]/g;
result = str.match(pattern);
but the result was: abc ,(24 ,314 ,83 ,383),(-256),sa ,0 ,(24 ,314),
0in the original string gone?