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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:49:51+00:00 2026-05-26T09:49:51+00:00

New to regex syntax here. Trying to write a regex to provide some input

  • 0

New to regex syntax here. Trying to write a regex to provide some input validation.

What I need is a regex to match a whole number, or a decimal with exactly one digit past the decimal.

Good Match
1
12
100
1.1
100.1
1.0

No Match
1.22
1.
0
012

Here is what I came up with but it doesn’t work:

Regex.IsMatch(paidHours, "\\d+[.]?[0-9]?")
  • 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-26T09:49:51+00:00Added an answer on May 26, 2026 at 9:49 am

    Edited answer after OP question edit.

    Regex.IsMatch(paidHours, @"^[1-9][0-9]*(\.[0-9])?$");
    

    Explanation:

    ^      : Start of the String
    [1-9]  : A single number between 1 and 9
    [0-9]* : Zero or more number(s) between 0 and 9 
             ([0-9]? would match zero or one number and the String "100" would not match the regex)
    (      : Start of a group
    \.     : A point
    [0-9]  : A single number between 0 and 9
    )?     : End of the group. The group must be repeated zero or one time
    $      : End of the String
    

    Please note that \d is not exactly equivalent to [0-9]: \d matches any unicode digit. For instance, this character ௮ will be matched if you use \d but won’t be if you use [0-9].

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

Sidebar

Related Questions

I am entirely new to regex, and am trying to use it to match
I am kinda new to this Regex thing. When analyzing some code I frequently
I'm new to .NET and having a hard time trying to understand the Regex
I very new to Python, and fairly new to regex. (I have no Perl
I know the regex for doing a global replace, %s/old/new/g How do you go
I am a Javascript Junkie and wishing to test around some codes. new RegExp(user=
im new with regexp, so can i ask for some assistance Using string.replace function
I am new to the RegEx and i want to be able to search
Regex rx = new Regex(@(?<!\\\\),); String test = OU=James\\, Brown,OU=Test,DC=Internal,DC=Net; This works perfectly, but
I'm really new to Regex and working hard, but this has gone beyond simple

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.