I have a string that contains alphabets and integer like banana12,apple123, i wanted to separate integer value from a string. I have used split() function its working perfectly for single digit number ( orange1 ) but for double digit number it is returning only single digit.
myString = banana12;
var splits = myString.split(/(\d)/);
var prodName = splits[0];
var prodId = splits[1];
the prodId should be 12 but its returning only 1 as result.
/(\d+)/instead!splititself is a bad choice here, what do you think?myStringis a sequence of multiple names & ids. Sure,.match(/([a-z]+)(\d+)/i)might be the better choice if not.