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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:44:24+00:00 2026-05-26T03:44:24+00:00

I am quite new to Python and I researched as much as I could

  • 0

I am quite new to Python and I researched as much as I could before I decided I should ask a question here. So here is the problem:

I am not sure what I am doing wrong with my RegEx. I wanted to try the re.findall() out, so I thought I would write a small script that would find phone numbers on webpages. Here is the code that I have right now.

    import re, urllib
    inurl = raw_input("Input a URL: ")
    web = urllib.urlopen(inurl)
    web.readlines()

    numbers = re.findall("/\d{3}.\d{3}.\d{4}/g", web)
    for itm in numbers
        print itm

Not sure what is happening. I keep getting the error of “expected string or buffer” for the line that has

    numbers = re.findall(".....", web)

Thanks in advance.

  • 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-05-26T03:44:25+00:00Added an answer on May 26, 2026 at 3:44 am

    /\d{3}.\d{3}.\d{4}/g – The /../ part is to identify regex in other languages like Ruby and g is a flag, also not applicable to Python. Try removing them and use just \d{3}.\d{3}.\d{4}

    Also I think you wanted to use the output / response in the findall and not just web, which is why you are seeing the expected string or buffer. You should also remove the line that just does web.readlines()

    So what you may want to do will be something like this:

    numbers = re.findall("\d{3}.\d{3}.\d{4}", web.read())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, first off I'm not quite sure how to phrase my problem. This could
I'm quite new with Python and programming in general. My problem concerns the operations
I'm creating a game, and am quite new to Python generally. I created a
Quite new to maven here so let me explain first what I am trying
I'm quite new to OpenId and I'm having a bit of a problem understanding
i am quite new in python. I am receiving (through pyserial) string with data
I'm quite new to python, so I'm doing my usual of going through Project
I'm quite new to threading in Python and have a couple of beginner questions.
i am quite new to python.subprocess() if i folk a new process from python,
I am quite new with Django, and I was wondering if I could document

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.