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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:32:04+00:00 2026-05-10T20:32:04+00:00

I am not very good with Regex but I am learning. I would like

  • 0

I am not very good with Regex but I am learning.

I would like to remove some html tag by the class name. This is what I have so far :

<div class="footer".*?>(.*?)</div> 

The first .*? is because it might contain other attribute and the second is it might contain other html stuff.

What am I doing wrong? I have try a lot of set without success.

Update

Inside the DIV it can contain multiple line and I am playing with Perl regex.

  • 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. 2026-05-10T20:32:05+00:00Added an answer on May 10, 2026 at 8:32 pm

    You will also want to allow for other things before class in the div tag

    <div[^>]*class='footer'[^>]*>(.*?)</div> 

    Also, go case-insensitive. You may need to escape things like the quotes, or the slash in the closing tag. What context are you doing this in?

    Also note that HTML parsing with regular expressions can be very nasty, depending on the input. A good point is brought up in an answer below – suppose you have a structure like:

    <div>     <div class='footer'>         <div>Hi!</div>     </div> </div> 

    Trying to build a regex for that is a recipe for disaster. Your best bet is to load the document into a DOM, and perform manipulations on that.

    Pseudocode that should map closely to XML::DOM:

    document = //load document divs = document.getElementsByTagName('div'); for(div in divs) {     if(div.getAttributes['class'] == 'footer') {         parent = div.getParent();         for(child in div.getChildren()) {             // filter attribute types?             parent.insertBefore(div, child);         }         parent.removeChild(div);     } } 

    Here is a perl library, HTML::DOM, and another, XML::DOM
    .NET has built-in libraries to handle dom parsing.

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

Sidebar

Related Questions

I'm not very good at regex but maybe there's a simple way to achieve
I'm not very good at PHP and would like to have a PHP function
Hi I have some experience with programming but I'm not very good with pointers.
I am not very good in regex but there is an illogic thing that
I am not very good at regular expression but want to do some thing
I'm not very good for regex and this is why I need your help.
I am not very good at regex, but I need to convert the following
Writing a simple regex, but I've never been very good at this. What I'm
I've got some HTML that looks like this: <tr class=row-even> <td align=center>abcde</td> <td align=center><a
I'm not that good with this REGEX string replace, but i think this problem

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.