I am using Nokogiri to parse an HTML document. I am trying to grab the price from a div and I need to use regex to get only part of the content.
I have the string
6.956.95
and I need to return just
6.95
another example, I have the string:
22.9522.95
and I just need
22.95
My regex skills are not great and I have been trying a lot of different approaches that have not worked. Thanks!
If you know you’ll always have a decimal:
That says select one or more digits from the front of your string, followed by a decimal, followed by up to 2 digits and it will ignore anything past that.