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 7954691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:30:25+00:00 2026-06-04T03:30:25+00:00

I need to grab a price from one element and add it to another.

  • 0

I need to grab a price from one element and add it to another.

I am using this:

\$\d+(?:\.\d+)?

Which seems to work for $0.50, $1.00, $20.00, $200.00 but I hit a brick wall on $1,000.00 and $10,000.00

(Unlikely $10,000.00 will ever be used).

The comma is tripping me up.

** Edit **

I went away for an hour to come back to heaps of answers. Before I go through them I thought I’d clarify rather than answering all comments:

The platform being used auto generates the total value of items in a shopping cart. It gets rendered in a an element – this changes depending on whether a user is adding or removing items.

The value is unlikely to go into 10,000.00 because the product costs are not that high.

I am new to using the regex it took me long enough to get this far, hence the question.

Auto generated HTML:

<span vertical="False" quote="False" id="catCartSummary">
   <table cellspacing="0" class="cartSummaryTable">
     <tbody>
       <tr>
         <td class="cartSummaryItem">3 item(s), Total: $115.00 <a href="#" class="cartSummaryLink">View Cart</a></td>
       </tr>
     </tbody>
   </table>
</span>

I just need the $ value in this case $115.00 – But I need it to work for $1,000.00

  • 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-04T03:30:27+00:00Added an answer on June 4, 2026 at 3:30 am

    Replace non-digit and non-dot simbols by '', then apply parseFloat:

    var currencyValue = parseFloat("$1,000.50".replace(/[^\d\.]/g,''));
    
    console.log( currencyValue ) ;   //1000.5
    

    UPDATE: If your ‘HTML Auto generator’ generates valid currency strings, then

    /\$\S+/g
    

    regexp is enough, for extracting all currencies:

    var currencies = $('#cartSummaryItem').text().match(/\$\S+/g);    // ["$115.00"]
    

    Then you could convert them to numbers for performing maths on them:

    var currenciesAsNumbers = currencies.map( function(item){
        return parseFloat( item.replace(/[^\d\.]/g,'') );
    });    // [115]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this jquery ui autocomplete but i need to grab the data
Heyho, I need to grab some datas from actions which been done from date
I need to grab a json-string from this page: https://retracted.com If you view the
I need to grab the text Home or 'Home' from this code: <%@ Page
I need grab the path of a referring URL, which can be served from
I need to grab all the FIELD and VALUES from a POST. I have
I need to grab the words out of this string and replace with AND
I need to grab several items from other page right now my jquerycalls looks
I need to grab the video ID from a Google Video URL. There are
I need to grab values from the querystring and inject them into a getURL();

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.