I have input lines like this:
1 soccer ball at 10
2 Iphones 4s at 199.99
4 box of candy at 50
And I want to get the first digit, the item itself and the price (I don’t want the “at”).
I have done the following regex:
/^(\d+)\sat\s(\d+\.?\d*)$/
But as you can see I am missing what comes before the “at”. What should I put there?
This should work for you.
/(\d+)\s+(.+?)\s+at\s+([\d\.,]+)/