Before asking this question, I looked into this, Previous Question
Currently, I need to find a regex that extracts any digits that are not preceded by $
symbol and it needs to work in IE which is why negative lookbehind can't be utilized.
My test strings is following
2 burgers and 3 drinks would be $15
The cost of 2 burgers and 3 drinks are $15
I want to retrieve 2,3
from the above two strings.
I have developed my regex as following by reading the previous post as following
/((?!([\$]))^)\d+|(?:[^\$])\b\d+/gm
I am not entirely sure if this is the correct one. If it is the correct one, the second issue is it is picking up the spaces. Even though I can replace the spaces later but I was wondering if there is a way to pick up the digits without spaces
var x = 'The cost of 2 burgers and 3 drinks are $15'
var y = x.match(/((?!([\$]))^)\d+|(?:[^\$])\b\d+/gm);
var z = y.toString().replace(/ /gm,'');
Thank you in advance.