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

  • Home
  • SEARCH
  • 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 584443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:53:54+00:00 2026-05-13T14:53:54+00:00

I need to parse an HTML file and i’ve got something like this: <TAG1>

  • 0

I need to parse an HTML file and i’ve got something like this:

<TAG1>
    <TAG1>
        TEXT_TO_FIND
        KEY
        <TAG1>
        </TAG1>
        <TAG1>
        </TAG1>
    </TAG1>
</TAG1>

Taking into account that there are multiple nesting levels. How can I get the text TEXT_TO_FIND?

In plain english, what I need to do is to get the text between "the last that has the text KEY after it" and "the text KEY", which only appearse once on the document.

Note1: I found this question but it didn’t seem to work; I kept getting an empty result. This would be the expression:

/<TAG1>(?!.*<TAG1>)(.*)KEY/ism

Note2: If I remove the KEY from the expression of the previous note, I get the text from the last to the end of file.

Thanks everyone 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-13T14:53:55+00:00Added an answer on May 13, 2026 at 2:53 pm

    If you just don’t want to use a HTML parser, this is a regexp that works if TEXT_TO_FIND does not contain “<” or “>”:

    /\s*([^<>]*?)\s*?KEY/ism
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this tag into my html file: {{block:my_test_block}} {{news:my_test_block2}} I need to parse
I have a string like this that I need to parse into a 2D
I need parse a select value in html file. I have this html file:
I'm using PHPQuery parse HTML file and I need the height and width of
Is there anything like Jsoup but instead of parsing HTML, I need to parse
I need to be able to parse an HTML template file (with the intention
I Need to parse a html file in python, and stock the content in
I need to parse many html files using php. foreach($url_array as $url){ $file =
I need to parse invalid HTML files that contain several random elements (like BODY)
I have a ~2 MB html file that I need to parse that contains

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.