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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:57:04+00:00 2026-05-28T14:57:04+00:00

Yes, yes, I’ve weighed using an xml parser instead of regular expressions, but this

  • 0

Yes, yes, I’ve weighed using an xml parser instead of regular expressions, but this seems to be a simplistic enough case that it’s suitable:

from BeautifulSoup import BeautifulSoup
from urllib import urlopen

tempSite = 'http://www.sumkindawebsiterighthur.com'
theTempSite = urlopen(tempSite).read()
currentTempSite = BeautifulSoup(theTempSite)
Email = currentTempSite.findAll('tr', valign="top") 
print Email[0] 

Currently results with:

<tr valign="top">
<td><p>Phone Number:</p></td>
<td>&nbsp;</td>
<td><p>706-878-8888</p></td>
</tr>

I’m trying to remove all markup (tr, td, p,   would be nice too) and result:

Phone Number: 706-878-8888

My problem is over-exclusion AND multiple lines being regex’d, looking for an answer that outputs on a single line.

  • 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-28T14:57:05+00:00Added an answer on May 28, 2026 at 2:57 pm

    If your results are really always that simple, the following regex will put ‘Phone Number:’ in capture group 1 and the number in capture group 2 as long as the re.DOTALL flag is set:

    .*(Phone Number:).*?([-\d]+).*
    

    You can then call re.sub() on your string with the replacement \1 \2.

    Here is a complete example that returns what you want:

    >>> s = """<tr valign="top">
    ... <td><p>Phone Number:</p></td>
    ... <td>&nbsp;</td>
    ... <td><p>706-878-8888</p></td>
    ... </tr>"""
    >>> regex = re.compile(r'.*(Phone Number:).*?([-\d]+).*', re.DOTALL)
    >>> regex.sub(r'\1 \2', s)
    'Phone Number: 706-878-8888'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

yes, I know that using regular expressions on html is not preferred, but I
Yes, I know you could use regular objects as associative arrays in JavaScript, but
Yes, I am having issues with this very basic (or so it seems) thing.
Yes, this is rather subjective, but I am doing research on that matter and
Yes I could google this but I'm being a little lazy. I need to
yes, this is a homework-type question but could you please help me out? In
yes i know how silly and dumb this question is, but i have been
Yes Vista sucks... I'm writing a Windows Service using .Net but getting security errors
Yes, getting the class name by using an exception is a plausible solution, but
Yes, I'm aware that this question has already been post, but ... I'm looking

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.