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

The Archive Base Latest Questions

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

I am not too good with regular expressions so this might be an obvious

  • 0

I am not too good with regular expressions so this might be an obvious question.

I want my expression to match if a certain number of characters are found and fail if any extra characters are present. For example if I have a string that should have 4 digits the following should be true.

1234 – match
ab1234cd – does not match
012345 – does not match

What I have so far is \d{4} but my understanding is that this would just match any string that has 4 digits together in it anywhere. I want to match only if a string contains 4 digits and nothing else.

Any help would be appreciated. Thanks.

  • 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-13T09:49:57+00:00Added an answer on May 13, 2026 at 9:49 am

    Use ^ and $ to mark the start/end of the string.

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

Sidebar

Related Questions

I'm not too good with css so this is probably a stupid question but...
I'm not too good with mod_rewrite or regular expressions, but I need to ultimately
Not too sure how to formulate my question and I hope that this is
I need some help with a query (sorry, I'm not too good at this!)
I'm not too good with SQL and I know there's probably a much more
Good afternoon, all. I'm not too hopeful for a yes here, but if anyone
Not too sure what's going on here as this doesn't seem like standard practise
Not too sure if I'm doing this right. It looks a bit more convoluted
I'm not too clear about this and neither are the docs. When I'm creating
I'm not too good at JS, but have survived thus far. I'm creating a

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.