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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:00:50+00:00 2026-06-10T07:00:50+00:00

I have the HTML from a page in a variable as just plain text.

  • 0

I have the HTML from a page in a variable as just plain text. Now I need to remove some parts of the text. This is a part of the HTML that I need to change:

<div class="post"><a name="6188729"></a>
    <div class="igmline small" style="height: 20px; padding-top: 1px;">
        <span class="postheader_left">
            <a href="#"  style="font-size:9pt;"> RuneRifle </a>
            op 24.08.2012 om 21:41 uur
        </span>
        <span class="postheader_right">
            <a href="http://link">Citaat</a> <a href="http://link">Bewerken</a>
        </span>
        <div style="clear:both;"></div>
    </div>
    <div class="text">Testforum</div>
    <!-- Begin Thank -->
    <!-- Thank End -->
</div>

These replaces work:

pageData = pageData.replace(/href=\".*?\"/g, "href=\"#\"");
pageData = pageData.replace(/target=\".*?\"/g, "");

But this replace does not work at all:

pageData = pageData.replace(
  /<span class=\"postheader_right\">(.*?)<\/span>/g, "");

I need to remove every span with the class postheader_right and everything in it, but it just doesn’t work. My knowledge of regex isn’t that great so I’d appreciate if you would tell me how you came to your answer and a small explanation of how it works.

  • 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-06-10T07:00:51+00:00Added an answer on June 10, 2026 at 7:00 am

    I need to remove every span with the class postheader_right and everything in it, but it just doesn’t work.

    Don’t use regular expressions to find the spans. Using regular expressions to parse HTML: why not?

    var allSpans = document.getElementsByClassName('span');
    for (var i = allSpans.length; --i >= 0;) {
      var span = allSpans[i];
      if (/\bpostheader_right\b/.test(span.className)) {
        span.parentNode.removeChild(span);
      }
    }
    

    should do it.

    If you only need to work on newer browsers then getElementsByClassName makes it even easier:

    Find all div elements that have a class of ‘test’

    var tests = Array.filter( document.getElementsByClassName('test'), function(elem){
      return elem.nodeName == 'DIV';
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On extracting some html from a web page, I have some elements containing text
If I have a string that contains the html from a page I just
I have HTML that I need to extract a part number from, the HTML
My question is this, if I have a page say index.HTML that has some
I have an HTML page that uses AJAX to retrieve messages from a server.
I have some html returned from an ajax call that contains blocks of html.
I have 2 websites, one of them just plain HTML and php, the other
On the first page I have this function: <script> function update() { $(#notice_div).html('Loading..'); $.ajax({
I'm working on a little project, basically I have some text on my PHP/HTML
I have a simple BufWritePost autocmd to automatically generate HTML from my vimwiki pages.

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.