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 didn'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 regexs.