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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:30:14+00:00 2026-06-11T16:30:14+00:00

I am trying to captcha a particular string with a regex, however I am

  • 0

I am trying to captcha a particular string with a regex, however I am losing the first char.

The string is
(06)12345678

My regex is

r'\b\((0[34679]{1})\)?([\- ]{0,1})[0-9]{3,4}([\- ]{0,1})[0-9]{3,5}'

but all I get in my match is

06)12345678

I really want that first ( also.

The ( and ) are conditional because sometimes there wont be ().
but the word boundary are there to prevent numbers like

hello123456789 

matching

regex = r'\b\(?(0[34679]{1})\)?([\- ]{0,1})[0-9]{3,4}([\- ]{0,1})[0-9]{3,5}'
matches = re.finditer(regex, '(06)12345678)')
for match in matches:
    print match.group(0)

any thoughts?

— examples —

(06)12345678 should match, (06)12345678
06 12345678 should match, 06 12345678
1234567890 should match, 1234567890
=12345678 no match
  • 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-11T16:30:15+00:00Added an answer on June 11, 2026 at 4:30 pm

    Try escape second "(", not first one, and the last but one ")" before first ?.

    Live demo: https://regex101.com/r/5h3FBr/1

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

Sidebar

Related Questions

I'm trying to create a Captcha in JavaScript but I ran into issues. I
New demo code: I am trying to get the captcha image from a AOL,
I'm trying to create a captcha code but the code that is being created
Trying to find some information on this but am unable to get any results
i am trying to get the simple captcha to work with my django. After
I'm trying to implement a simple captcha into a form I'm building but I've
I'm trying to make a captcha system that isn't the same as all the
I'm trying to implement Recaptcha to Silverstripe, it is all working well but the
I am trying to set my own custom error message onto my Captcha but
I am trying to use the drop event of fancy captcha (http://www.webdesignbeach.com/beachbar/ajax-fancy-captcha-jquery-plugin) but it

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.