Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9231041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:58:19+00:00 2026-06-18T05:58:19+00:00

I am using Nokogiri to parse an HTML document. I am trying to grab

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:58:20+00:00Added an answer on June 18, 2026 at 5:58 am

    If you know you’ll always have a decimal:

    ^\d+\.\d{0,2}
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to parse a HTML table from a URL using Nokogiri. My HTML
Using Nokogiri, I need to parse a block given: <div class=some_class> 12 AB /
I am using mechanize/nokogiri and need to parse out the following HTML string. can
I'm trying to parse the Twitter usernames from a bit.ly stats page using Nokogiri:
For following HTML, I want to parse it and get following result using Nokogiri.
I am using mechanize/nokogiri and need to parse out a HTML with a lot
I need to parse HTML using Rails and Nokogiri. Here is the HTML: <body>
I have some very bare HTML that I'm trying to parse using Nokogiri (on
I'm using Nokogiri to parse an XML response from last.fm. I am currently returning
I am trying to parse XML files using Nokogiri, Ruby and XPath. I usually

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.