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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:29:39+00:00 2026-05-30T16:29:39+00:00

How can I use regex to find everything except for data within div with

  • 0

How can I use regex to find everything except for data within div with a specific style? e.g.

<div style="float:left;padding-left:10px; padding-right:10px">
    <img src="../Style/BreadCrumbs/Divider.png">
</div>
<div style="float:left; padding-top:5px;">
    Data to keep
</div>
<div style="float:left;padding-left:10px; padding-right:10px">
    <img src="../Style/BreadCrumbs/Divider.png">
</div>

I want regex to match everything except for the data. The best way I can see is to just remove the html markup and combine the files afterwards with vb (I already have the code for vb.)

I’m using regex because I need to extract the data from several hundred files.

  • 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-30T16:29:40+00:00Added an answer on May 30, 2026 at 4:29 pm

    Your suggested method is probably not a good way to do this. If:

    • you have access to grep
    • your version of grep supports perl-compatible regex (PCRE)
    • this style of div only wraps your data, not other elements
    • the ‘data’ div does not contain other divs

    Then you can use:

    (?s)<div style="float:left; padding-top:5px;">.*?</div>
    

    The important parts of this are:

    • (?s) which activates DOTALL, which means that . will match newlines
    • .*? which matches the contents of the div reluctantly, which means it’ll stop at the first </div> it finds.

    To use this, you’ll need to activate a few grep options:

    grep -Pzo $PATTERN file
    

    For these:

    • -P activates the PCRE
    • -z replaces \n by NUL so grep will treat the entire file as a single line
    • -o prints only the matching parts

    After this you’ll need to strip off the divs. sed is a good tool for this.

    sed 's|</\?div[^>]*>||g'
    

    If you put all of your files in one directory you can do the joining at the same time:

    grep -Pzo $PATTERN *.html | sed 's|</\?div[^>]*>||g' > out.html
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to find a regex to limit what a person can use
I don't know if I can use regex for this, but I want to
Can you use two regex in preg_replace to match and replace items in an
Initiated by the reply . How can I use only Regex instead of wildcards?
I want to use a regex to find the parent node of the 16
In Perl, how can I use one regex grouping to capture more than one
Couldn't find a function for this. I'm assuming I need to use regex? I'm
I am trying to use a regex to find text inside a string. For
how can i use Regex Expressions in C programming? for example if i want
You can use more than one css class in an HTML tag in current

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.