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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:16:54+00:00 2026-05-18T02:16:54+00:00

str1 = abdk3<h1>The content we need</h1>aaaaabbb<h2>The content we need2</h2> We need the contents inside

  • 0
str1 = abdk3<h1>The content we need</h1>aaaaabbb<h2>The content we need2</h2>

We need the contents inside the h1 tag and h2 tag.

What is the best way to do that? Thanks

Thanks for the help!

  • 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-18T02:16:55+00:00Added an answer on May 18, 2026 at 2:16 am

    The best way if it needs to scale at all would be with something like BeautifulSoup.

    >>> from BeautifulSoup import BeautifulSoup
    >>> soup = BeautifulSoup('abdk3<h1>The content we need</h1>aaaaabbb<h2>The content we need2</h2>')
    >>> soup.h1
    <h1>The content we need</h1>
    >>> soup.h1.text
    u'The content we need'
    >>> soup.h2
    <h2>The content we need2</h2>
    >>> soup.h2.text
    u'The content we need2'
    

    It could be done with a regular expression too but this is probably more what you want. A larger example of what you are wanting could be good. Without knowing quite what you’re wanting to parse it’s hard to help properly.

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

Sidebar

Related Questions

I have strings that all have different lengths. e.g. str1 = This is new
I have strings that are formatted as below: Houston, TX - str1 Chicago, IL
I have a string: str1 <- This is a string, that I've written to
Is there a StartsWith(str1, str2 string) function that can check if str1 is a
I have two strings str1 and str2 . Is there any algorithm that can
Is there a way to get str1 in code ? [MyAttribute(str1)] class X {}
Possible Duplicate: Best XML Parser for PHP -----First XML-----str1 <HOME> <USER_DETAIL> <LOCATION><![CDATA[MUMBAI]]></LOCATION> <NAME><![CDATA[RAVI]]></NAME> <ID><![CDATA[101]]></ID>
I need to insert string in another string in specific index. var str1:String =
I tried to make a function that replaces all occurrences of str1 in a
string str1(someString); string str2 = string(str1);//how many copies are made here //copy2 = copy1?

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.