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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:16:33+00:00 2026-05-24T13:16:33+00:00

Apologies if this is a simple question, I’m still pretty new to this, but

  • 0

Apologies if this is a simple question, I’m still pretty new to this, but I’ve spent a while looking for an answer and haven’t found anything. I have a list that looks something like this horrifying mess:

['Organization name} ', '> (777) 777-7777} ', ' class="lsn-mB6 adr">1 Address, MA 02114 } ', ' class="lsn-serpListRadius lsn-fr">.2 Miles} MORE INFO YOUR LISTING MAP if (typeof(serps) !== \'undefined\') serps.arrArticleIds.push(\'4603114\'); ', 'Other organization} ', '> (555) 555-5555} ', ' class="lsn-mB6 adr">301 Address, MA 02121 } ', ' class="lsn-serpListRadius lsn-fr">.2 Miles} MORE INFO CLAIM YOUR LISTING MAP if (typeof(serps) !== \'undefined\') serps.arrArticleIds.push(\'4715945\'); ', 'Organization} ']

And I need to process it so that HTML.py can turn the information in it into a table. For some reason, HTML.py simply can’t handle the monster elements (eg. ‘class=”lsn-serpListRadius lsn-fr”>.2 Miles} MORE INFO YOUR LISTING MAP if (typeof(serps) !== \’undefined\’) serps.arrArticleIds.push(\’4603114\’); ‘, etc). Fortunately for me, I don’t actually care about the information in the monster elements and want to get rid of them.

I tried writing a regex that would match all more-than-two-letter all-caps words, to identify the monster elements, and got this:

re.compile('[^a-z]*[A-Z][^a-z]*\w{3,}')

But I don’t know how to apply that to deleting the elements containing matches to that regex from the list. How would I do that/is that the right way to go about it?

  • 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-24T13:16:34+00:00Added an answer on May 24, 2026 at 1:16 pm

    I think your regex is incorrect, to match all entries that contain all-cap words with three or more characters, you should use something like this with re.search:

    regex = re.compile(r'\b[A-Z]{3,}\b')
    

    With that you can filter using a list comprehension or the filter built-in function:

    full = ['Organization name} ', '> (777) 777-7777} ', ' class="lsn-mB6 adr">1 Address, MA 02114 } ', ' class="lsn-serpListRadius lsn-fr">.2 Miles} MORE INFO YOUR LISTING MAP if (typeof(serps) !== \'undefined\') serps.arrArticleIds.push(\'4603114\'); ', 'Other organization} ', '> (555) 555-5555} ', ' class="lsn-mB6 adr">301 Address, MA 02121 } ', ' class="lsn-serpListRadius lsn-fr">.2 Miles} MORE INFO CLAIM YOUR LISTING MAP if (typeof(serps) !== \'undefined\') serps.arrArticleIds.push(\'4715945\'); ', 'Organization} ']
    regex = re.compile(r'\b[A-Z]{3,}\b')
    # use only one of the following lines, whichever you prefer
    filtered = filter(lambda i: not regex.search(i), full)
    filtered = [i for i in full if not regex.search(i)]
    

    Results in the following list (which I think is what you are looking for:

    >>> pprint.pprint(filtered)
    ['Organization name} ',
     '> (777) 777-7777} ',
     ' class="lsn-mB6 adr">1 Address, MA 02114 } ',
     'Other organization} ',
     '> (555) 555-5555} ',
     ' class="lsn-mB6 adr">301 Address, MA 02121 } ',
     'Organization} ']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if this is a simple question but googling hasn't been able to help
Apologies for probably simple question, I've read the docs and still can't get this
Apologies about this simple question. Still struggling with some of the memory concepts here.
My apologies if this is a duplicate question, but I haven't come across anything
I apologies for this being a very simple question but as a first time
I'm fairly new to Rspec so apologies if this is a really simple question:
Apologies if this is a stupid/easy question, but still getting used to everything in
Apologies if this is an overly simple question, but my searches are getting me
I'm pretty sure it hasn't, but apologies if this question has already been asked.
Apologies if this is simple question, but Im extremely worn down and though thinking

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.