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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:56:51+00:00 2026-06-09T12:56:51+00:00

My reg ex skills are almost zero and I am trying to match a

  • 0

My reg ex skills are almost zero and I am trying to match a field to have exactly 7 or 9 numbers (not between 7 or 9 so no 8 numbers is not valid).

I have tried (don’t laugh)

/^([0-9]{7} | [0-9]{9})

and

/^([0-9]{7 | 9})

if someone could help and explain the answer that would be much appreciated.

I assume (maybe incorrectly) that is does not matter what (programming) language I am using

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-06-09T12:56:52+00:00Added an answer on June 9, 2026 at 12:56 pm
    /^\d{7}(?:\d{2})?$/
    

    \d is modern regex shorthand for [0-9], using (?: prevents a group capture you don’t want or need from happening.

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

Sidebar

Related Questions

I have a strange problem with reg expression. I'm trying to getting out the
Currently i'm using this reg exp: var valid = (value.match(/^\d+$/)); But for digits like
I have this reg ex var id = url.match(/(\d+)\/\d+$/)[1]; that is parsing a url
I have such code reg = /(.+)_path/ if reg.match('home_path') puts reg.match('home_path')[0] end This will
I have created a function using reg-ex to validate a field in JavaScript. My
What reg expression patten to I need to match everything between {{ and }}
I have a reg file which I'm trying to read. There's a type dword
123-reg are my web host and they dont have a control panel to convert
i am generating *.reg file using code which will have some important data. and
I'm using startswith reg exp in Javascript if ((words).match(^ + string)) but if I

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.