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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:50:39+00:00 2026-06-11T08:50:39+00:00

it seems that i got a bug in python: (Python 2.7.3 (default, Apr 10

  • 0

it seems that i got a bug in python: (Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32)

>>> re.match("0[5-7][5-9][0-9]{7}", "0775123456") #match
<_sre.SRE_Match object at 0x0000000002D3FC60>

>>> re.match("0[5-7][5-9][0-9]{7}", "077512345") #dont match

>>> re.match("0[5-7][5-9][0-9]{7}", "07751234567") #match!
<_sre.SRE_Match object at 0x0000000002D3F920>

>>> re.match("0[5-7][5-9][0-9]{7}","07751234567777777777777777777777777777777777777777777777") #match!!
<_sre.SRE_Match object at 0x0000000002D3FC60>

so i must use the dollar sign to limit “exactly” the numer!
i think it’s a bug, because in HTML5 validation, the {7} means “exactly” 7 digits, and here in python, it seems that it means “at least”
and here is how it behaves using the dollars sign:

>>> re.match("0[5-7][5-9][0-9]{7}$", "0775123456") #match
<_sre.SRE_Match object at 0x0000000002D3F920>

>>> re.match("0[5-7][5-9][0-9]{7}$", "07751234567") #dont match

>>> re.match("0[5-7][5-9][0-9]{7}$", "077512345") #dont match

and this happens to all other regular expression, not only the exact number matching, the dollar must be added!

so is it a bug? or it’s by design?

  • 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-11T08:50:40+00:00Added an answer on June 11, 2026 at 8:50 am

    This is by design. re.match matches at the beginning of a string as opposed to re.search, which matches anywhere in a string. Extra characters after the string are ignored. See http://docs.python.org/library/re.html#match for more details.

    Other languages that also use regular expressions, such as grep and perl, act the same. Regular expressions are primarily used for searching text.

    If you want to perform an exact match you have to specify the dollar sign as you yourself also noted.

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

Sidebar

Related Questions

I'm trying to do a method like that, bug got concurrency problems.. seems like
I have got a memory bug that seems to boil down to something happening
It seems that NHibernate Linq doesn't understand grouped .Where method conditions. I got the
I've got a handmade ORM in PHP that seems to be bumping up against
I've got a weird issue that almost seems like a Visual Studio 2008 issue.
[EDIT] It seems that there is a bug in the XML Editor I'm using
I've got a regex that does matching for a template system, which unfortunately seems
I've got a strange bug, well, MSIE does. Seems it is failing on all
I've got model that use ExtendAssociations , but for some reason deleteHABTM doesn't seem
This question got me thinking about bare strings. When PHP sees a string that's

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.