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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:23:12+00:00 2026-06-12T17:23:12+00:00

I need to create a regex expression for the following scenario. It can have

  • 0

I need to create a regex expression for the following scenario.

It can have only numbers and only one dot or comma.

First part can have one to three digits.
The second part can be a dot or a comma.
The third part can have one to two digits.

The valid scenarios are

123,12
123.12
123,1
123
12,12
12.12
1,12
1.12
1,1
1.1
1

I came up so far with this expression

\d{1,3}(?:[.,]\d{1,2})?

but it doesn’t work well. For example the input is 11:11 is marked as valid.

  • 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-12T17:23:13+00:00Added an answer on June 12, 2026 at 5:23 pm

    You need to put anchors around your expression:

    ^\d{1,3}(?:[.,]\d{1,2})?$
    

    ^ will match the start of the string

    $ will match the end of the string

    If those anchors are missing, it will partially match on your string, since the last part is optional, means on “11:11” it can match on the digits before the colon and a second match will be on the digits after the colon.

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

Sidebar

Related Questions

I have the following string: $/Mycollection/Branches/Dev/New/php/MySite/src/MySite/somefolder/src/sad.php I need to create regex pattern and take
How I can create a regular expression for the following problem: I have a
Does anyone have any ideas on if/how one could create a regular expression to
I need to know if it's safe to create a static Regex object like
I need create clone repository. but I do not know where can I get
I need create a document word with Java. And I ask, how can I
I have dynamically created WrapPanel (_wp) with several Borders. And I need create handler
I need to create a WP site which will have multiple subjects. Each subject
Can anyone give me a clue, how to create/call function regular expression syntax in
I need to create a formatting documentation. I know the regex that are used

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.