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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:53:48+00:00 2026-06-07T18:53:48+00:00

>>> match = re.findall(r’\w\w’, ‘hello’) >>> print match [‘he’, ‘ll’] Since \w\w means two

  • 0
>>> match = re.findall(r'\w\w', 'hello')
>>> print match
['he', 'll']

Since \w\w means two characters, ‘he’ and ‘ll’ are expected. But why do ‘el’ and ‘lo’ not match the regex?

>>> match1 = re.findall(r'el', 'hello')
>>> print match1
['el']
>>>
  • 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-07T18:53:50+00:00Added an answer on June 7, 2026 at 6:53 pm

    findall doesn’t yield overlapping matches by default. This expression does however:

    >>> re.findall(r'(?=(\w\w))', 'hello')
    ['he', 'el', 'll', 'lo']
    

    Here (?=...) is a lookahead assertion:

    (?=...) matches if ... matches next, but doesn’t consume any of the
    string. This is called a lookahead assertion. For example,
    Isaac (?=Asimov) will match 'Isaac ' only if it’s followed by 'Asimov'.

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

Sidebar

Related Questions

I use re.findall(p, text) to match a pattern generally, but now I came across
I have this regex to match one of these two possibilities: (\b(Q|L[A-Z])\d{8}\b) # Possibilities
I want to find all items in one collection that do not match another
Match match = Regex.Match(555-5555555, ^(\\d{3}\\-?\\d{3}\\-?\\d{4})$, RegexOptions.None); it[Should match] = () => match.Success.should_be_true(); The above
match.matches() returns false. This is odd, because if I take this regex and test
String match = hello; String text = 0123456789hello0123456789; int position = getPosition(match, text); //
I am trying to match part of a file path if it does not
I'm confused about python greedy/not-greedy characters. Given multi-line html, return the final tag on
Is there any application for a regex split() operation that could not be performed
I'm having trouble with this regex and I think I'm almost there. m =re.findall('[a-z]{6}\.[a-z]{3}\.[a-z]{2}

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.