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

  • Home
  • SEARCH
  • 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 8470037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:24:03+00:00 2026-06-10T16:24:03+00:00

I am still a newbie in regular expression, please help me out guys. I

  • 0

I am still a newbie in regular expression, please help me out guys.

I have this html file, some of the paragraphs contains dollar values ($200, $300 etc). Whenever a user visits that file it will convert those values into their own currency.

I want to use regular expression to look for those values and have proper conversion.

Thanks in advance!

  • 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-10T16:24:04+00:00Added an answer on June 10, 2026 at 4:24 pm

    Here is a working example with few assumptions. I believe you have the conversion factor and you can substitute the actual value with the conversion factor.

    Edit: modified to allow conversion only for the matching numerical values. Numerical values are assumed to be positive integer values.

    Fiddle here http://jsfiddle.net/gbsandeep/eBQFE/

    Example:

    • Converted from currency “$” to hypothetical currency with symbol “@”

    • Conversion factor: 0.05

    Input

    $200 some $100 content goes $300 here

    Output

    @10 some @5 content goes @15 here

     function convert() {
         var replacedText = document.getElementById('myPara').innerText;
         var newCurrencySymbol = '@';
         var currencyConversionFactor = 0.05;
         var numberPattern = /\$\d+/g;
         var numbers = replacedText.match(numberPattern);
         for (var i = 0; i < numbers.length; i++) {
             // extract numerical value
             var num = numbers[i].match(/\d+/);
             // your currency conversion here
             var newNum = newCurrencySymbol + (num * currencyConversionFactor);
             replacedText = replacedText.replace(numbers[i], newNum);
         }
         document.getElementById('convertedPara').innerText = replacedText;
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Still having issues with this problem. Please help if you can. So I am
I'm still a C++ newbie who has only recently learned some file manipulation. I
I am still newbie to android, please could someone help. I want to use
little help guys im still a newbie at c++ error: invalid conversion from 'VboVO*
I'm realizing what a newbie I still am with this problem I have. I
I bit confuse with __unicode__() in django. I'm still a newbie. I have this
Please be easy on me and don't shoot me as I'm still newbie. I'm
Im still a newbie in android, would appreciate your help as I couldnt find
I'm still a newbie at flash, but is it possible to have Flash get
It's really a silly question since I'm still newbie ! Case : Solution contains:

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.