I have the following regex in javascript. I want to match a string so its product (,|x) quantity, each price
. The following regex does this; however it returns an array with one element only. I want an array which returns the whole matched string first followed by product, quantity, each price.
// product,| [x] quantity, each price:
var pQe = inputText.match(/(^[a-zA-z -]+)(?:,|[ x ]?) (\d{0,3}), (?:each) ([£]\d+[.]?\d{0,2})/g);
(,|x) means followed by a comma or x, so it will match ice-cream, 99, $99
or ice-cream x 99, $99
How can I do that?