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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:11:34+00:00 2026-05-28T20:11:34+00:00

Revised I’m trying to make a Regex Expression that parsed floating point numbers. At

  • 0

Revised

I’m trying to make a Regex Expression that parsed floating point numbers.

  1. At most 1 negative (-)
  2. At most 1 decimal (.)
  3. At most 3 digits to the left of the decimal
  4. At most 3 digits to the right of the decimal

I’m at the point where I tried the following:

Regex regex = new Regex(@"^(([\-]?|[\.]?|[\-\.]?|[0-9]?)([0-9]{0,3}))");
bool isMatch = regex.IsMatch(text);

However, inputs like "–" still pass

  • 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-28T20:11:35+00:00Added an answer on May 28, 2026 at 8:11 pm

    If you have to do regex:

    How about ^-{0,1}\d{0,3}(?:.{0,1}(?<=.)\d{0,3})?$

    Here it is with some test values

    with regards to the onchange event. I don’t know what format you’re using. In MVVM, the binding will keep the box from being changed incorrectly. In windows forms, you’ll, have to change it yourself. I’d say store the value whenever it’s good to a private property. THen, if the change is invalid, return to the previous value.

    additionally, the test in c#

    using System;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    
    namespace ConsoleApplication4
    {
        class Program
        {
            static void Main(string[] args)
            {
                Regex rx = new Regex(@"^-{0,1}\d{0,3}(?:\.{0,1}(?<=\.)\d{0,3})?$");
                List<string> testStrings = new List<string>()
                {
                    "100",
                    "100.100",
                    "1000.0000",
                    "100000",
                    "-1",
                    "-1.234",
                    "--",
                    "100.100ab",
                    "1,234.1",
                    "1,234",
                    "abc",
                    "abc123.123",
                    "abc.def"
                };
                foreach(var str in testStrings)
                {
                    Console.WriteLine(string.Format("{0} = {1}", str, rx.IsMatch(str)));
                }
                Console.ReadLine();
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

[revised] I'm creating a TreePanel in ExtJs that is loading its children from a
When people refer to the revised syntax in OCaml, do they mean that this
Revised: I have a list items on the page that I'm creating from database
(Didn't mean to create a new question, but revised the old one enough that
I'm trying to scale a container/parent movie clip up so that I effectively zoom
REVISED: Are there any jQuery plugins that can revolve one element around another? EDIT:
REVISED QUESTION I have revised the original question (as seen below) so that I
Revised Code jQuery(function($) { $(#filter).keyup(function () { var filter = $(this).val(), count = 0;
REVISED QUESTION : We have tracked this down to a custom add to cart
UPDATE: Solved. Thanks BusyMark! EDIT: This is revised based on the answer below from

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.