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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:09:36+00:00 2026-05-31T05:09:36+00:00

I am looking to create a regular expression in javascript that does the following:

  • 0

I am looking to create a regular expression in javascript that does the following:

  1. Allows for 1 or more numbers
  2. Then has an optional period (“.”)
  3. Then has an optional number of digits up to 6

The context is that i need people to enter in numeric values in the millions and i want them to at least include a 0 if they are entering thousands… so they could enter the following:

1 (would be one million)
0.725 (would be 725k)
10.5 (would be 10M 500K)

I also need to ensure that the value doesn’t reach over 725.00 (or 725 million).

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-05-31T05:09:37+00:00Added an answer on May 31, 2026 at 5:09 am

    So basically you want a number that would be multiplied by 10^6 to get the true value.

    This sounds like a two-stepper; First, verify that the input string is in a format you expect (you can use a regex for this very easily). Then, parse the string into a number variable and test the actual value. The regex pattern for that would look like "[0-9]{1,3}(\.[0-9]{1,6})?", basically matching a number with up to 3 whole digits and 6 fractional digits, the decimal place and fractional digits being optional. If it matches this pattern, then it’s parsable into a number, and you can then perform a quick check that your number <= 725.

    I honestly don’t think it’s feasible to create a single Regex that can validate a proper numeric format AND an inclusive maximum range, but here’s a start:

    "^(725(\.0{1,6})|(([7][2][0-4]|[7][0-1][0-9]|[1-6][0-9]{2}|[1-9][0-9]|[0-9])(\.[0-9]{1,6})?)$"

    This will allow any natural whole number from zero to 724, with any fractional part up to six digits from “.000001” to “.999999”. It does this in stages; it will match 720-724, or 700-719, or any three-digit number up to 699, or any two-digit number, or any one-digit number. Then, it will also match the quantity “725” explicitly, with an optional decimal point and up to 6 zeroes.

    EDIT: While your comment states that you used this pattern, and it does produce the correct result, I had intended it as a “what not to do”; this pattern will be far more costly to evaluate than the first solution, just to avoid a server-side rule check. And you will have to perform a server-side validation anyway; anything done within the confines of the user’s browser should be suspect because the user can disable JavaScript or can even use browser plug-ins like FireBug to make your HTML page behave the way he wants, instead of the way you designed it.

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

Sidebar

Related Questions

I am looking for help in how to create a regular expression that extracts
I am looking to create several sub-expressions in a larger regular expression, where each
I'm looking for how to create a regular expression, which is 100% equivalent to
I looking to create a custom calender with Zend Framework, I am hoping that
Im looking to create a control that would look like comic baloon. In WPF
I am looking to create a SQL query that collects the results from multiple
I'm looking to create a PHP function that can trim each line in a
I am looking to create a rails route that is capable of accepting requests
Looking for some implementation advice: I have a page that has a 3-tab ajaxToolkit:TabContainer.
I am looking for a regular expression which accepts the text with spaces and

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.