Thread: REGEX delete
View Single Post
Old 03-14-2024, 01:40 PM   #5
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 36,803
Karma: 147879470
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by Turtle91 View Post
You can even do it with one regex...ASSUMING you do not have nested <div>s:

Code:
find: <div.*?class="Basic-Text-Frame">(.*?)</div>
replace:\1
or TagMechanic
Personally, I would use TagMechanic since it handles nested divs. The code above would stop on the first </div> rather than the matching </div> which would break nested <div>s. In the example below, a regex search would match on the first </div> bolded rather than the last </div> bolded. And yes, this is from a real ebook produced by Vellum. The only change is replacing the first <div> with the sample from the OP.

Code:
  <div id="_idContainer020" class="Basic-Text-Frame"> 
    <div class="heading">
      <div class="heading-contents">
        <div class="title-block">
          <div class="element-number-block">
          </div>
          <div class="title-block">
            <h1 class="title">Chapter 2</h1>
          </div>
        </div>
      </div>
    </div>
  </div>
DNSB is online now   Reply With Quote