Say i have the following string:
var str1 = "62y^2";
and i want the following result:
[62,y,^2]
Now when i tried the below regex i did't get the desired result:
str.match(/(\d*)|([a-zA-Z]*)|(\^[a-zA-Z\d]*)/g)
But when i try the below regex:
str.match(/\^(\d+|[a-zA-Z]+)|[a-zA-Z]+|\d+/g);
I get the desired result, why is my first regex not working ? is it because of the capture groups , i am not so well versed in regex's so any help would be much appreciated.