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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:55:17+00:00 2026-06-12T07:55:17+00:00

I tried the solution for phone numbers with 7-12 digits that may contain spaces

  • 0

I tried the solution for phone numbers with 7-12 digits that may contain spaces or hypens in the following link. The first and last character has to be a number.

Regular expression to match 7-12 digits; may contain space or hyphen

However, i’m not understanding the regex well.

$phone_pattern="/^\d(?:[-\s]?\d){6,11}$/";

what does the “:” mean here?

How is this regex able to exclude the hypens and spaces from the 6 to 11 characters?

Help help is highly appreciated

  • 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-12T07:55:19+00:00Added an answer on June 12, 2026 at 7:55 am

    Have you tried a testing engine like regexpal (there are others available also) I frequently use this to test various strings against expressions to make sure they are behaving as expected.

    My understanding is that in this case the : is not acting alone it is acting in conjunction with the ?

    The ? in this circumstance does not mean Preceding zero or one times it is a modifier meaning give this group a new meaning which in conjunction with the modifier : turn off capture means you want this to be a non capturing group expression.

    The effect that this has is that when placing part of an expression inside () it by default causes capture but ?: switches this off.

    Thus (?:[-\s]?\d) becomes a non capturing group expression.

    Note captured groups are used with back references and most regex engines support up to 9 back references.

    So removing capture speeds up the matching process and allows you to elect not to refer back to that group saving one of your 9 references for a group that you really do want to refer back to.

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

Sidebar

Related Questions

gem install heroku failed with following message and I have tried the solution here
I'm trying to remove scrollbar from my facebook app. I tried js solution, that
I tried to find an easy solution for the following. I have a main
As the title conveys, I want to have a UILabel that will contain phone
I tried the solution from this thread , but I must be missing something
I tried multiple solution but none seem to work. Layout: -------------------- |btn1| txt1 |btn2|
I've tried the solution here , but it doesn't work. My table is like
hello i am having same issue, i tried your solution but it didnt help
I tried to find a solution but I didn't found what I was searching
I tried to find a solution to my problem already in google and here

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.