Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 03-13-2024, 04:16 PM   #1
swepub
Swepub
swepub began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Dec 2023
Device: iPad
REGEX delete

Completely new to this.
Is it possible to remove all <div ids and it's corresponding end <\div> like below that has the class "Basic-Text-Frame" using regex?
<div id="_idContainer020" class="Basic-Text-Frame">
swepub is offline   Reply With Quote
Old 03-13-2024, 04:50 PM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 7,647
Karma: 5433388
Join Date: Nov 2009
Device: many
Uses Find and Replace in regex mode, or the TagMechanic plugin for even easier use.

See the Sigil Users Guide for more info.
KevinH is online now   Reply With Quote
Old 03-14-2024, 09:42 AM   #3
retiredbiker
Addict
retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.retiredbiker ought to be getting tired of karma fortunes by now.
 
retiredbiker's Avatar
 
Posts: 387
Karma: 1638210
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, Jutoh, Kobo Forma
Quote:
Originally Posted by swepub View Post
Completely new to this.
Is it possible to remove all <div ids and it's corresponding end <\div> like below that has the class "Basic-Text-Frame" using regex?
<div id="_idContainer020" class="Basic-Text-Frame">
One way to do it: Using regex mode, search for
<div.*?class="Basic-Text-Frame">
and replace with nothing.
Check it out one-at-a-time at first to make sure it is doing what you want, before hitting Replace All.
Then use the Mend and Prettify All HTML files tool to get rid of the </div> tag ends left behind.

Also try the plugin KevinH mentions, and do spend some time with the manual and regex tutorials. Regex is powerful and can easily destroy a book.
retiredbiker is offline   Reply With Quote
Old 03-14-2024, 10:12 AM   #4
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,095
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
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
Turtle91 is online now   Reply With Quote
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: 35,464
Karma: 145525534
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, 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 offline   Reply With Quote
Old 03-14-2024, 03:24 PM   #6
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 3,095
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
Yup. That’s why I said “assuming you don’t have nested divs!”
Turtle91 is online now   Reply With Quote
Old 03-14-2024, 05:06 PM   #7
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: 35,464
Karma: 145525534
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Forma, Clara HD, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by Turtle91 View Post
Yup. That’s why I said “assuming you don’t have nested divs!”
I noticed that you said that but I wanted to emphasize it!

One of the first ePubs I got to try repairing was one where original editor used regex to make changes to some spans and the (unnecessary in my opinion), nested spans were munged which made the ePub almost unreadable. The original was bad enough before the edit with massive dropcaps which after the edit applied to the entire paragraph.
DNSB is offline   Reply With Quote
Old 03-16-2024, 06:48 AM   #8
swepub
Swepub
swepub began at the beginning.
 
Posts: 13
Karma: 10
Join Date: Dec 2023
Device: iPad
Thanks a lot for great support.
TagMechanic did the trick...
swepub is offline   Reply With Quote
Reply

Tags
regex


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
pdf regex question - regex that wraps to a new line flyash Conversion 1 09-05-2021 09:00 AM
Predefined regex for Regex-function sherman Editor 3 01-19-2020 05:32 AM
Q: Regex Find and Replace delete surrounding tags hidden.platypus Editor 14 06-16-2015 11:16 PM
python regex: delete text in preprocessing sws Recipes 0 01-11-2013 09:01 AM
Delete files in PC not equal to delete in Sony reader 505 sheilalayoli Sony Reader 5 07-12-2009 03:13 PM


All times are GMT -4. The time now is 03:18 PM.


MobileRead.com is a privately owned, operated and funded community.