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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:54:46+00:00 2026-06-09T10:54:46+00:00

I am trying to match a string containing 1 to 3 digits, example: 1

  • 0

I am trying to match a string containing 1 to 3 digits,

example:

1
 2
123
  3

This is what i tried,

[\s]?[0-9]{1,3}[\s]?

This is matching,

123 ->a space after 123
  • 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-09T10:54:48+00:00Added an answer on June 9, 2026 at 10:54 am

    Your question is unclear, but it seems you’re looking for a string that

    • is exactly 3 characters long
    • contains only digits or whitespace
    • contains at least one digit

    In that case, the regex is ^(?=.*\d)[\d\s]{3}$. As a Java string: "^(?=.*\\d)[\\d\\s]{3}$".

    Explanation:

    ^         # Start of string
    (?=.*\d)  # Assert that there is at least one digit in the string
    [\d\s]{3} # Match 3 digits or whitespace characters
    $         # End of string
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to match a string containing a mix of digits and hyphenated
first, this is using preg. String I'm trying to match: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa b c d
Trying to match string like this: /2011/10/Lorem-ipsum-dolor-it-amet-consectetur-adipisicing /2011/10/Lorem-ipsum-dolor-it-amet-consectetur-adipisicing/ and /2011/10/4545 /2011/10/4545/ And get year,
I'm trying to match a string that looks something like this: <$Fexample text in
I am trying to match on this string $0.05/$0.10 and came up with this
I'm trying to match a string against a pattern, but there's one thing I
I am trying to match a string only if it is not part of
I am trying to match on a string that begins with ./media I have
I'm trying to match the whole string and not just part of it. For
I'm trying to use regex to match a string that starts with a <p>

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.