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, 05:16 PM   #1
swepub
Swepub
swepub began at the beginning.
 
Posts: 23
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, 05: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: 8,160
Karma: 5450818
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 offline   Reply With Quote
Advert
Old 03-14-2024, 10:42 AM   #3
retiredbiker
Evangelist
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: 420
Karma: 2737916
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, 11: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,225
Karma: 19000635
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/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 offline   Reply With Quote
Old 03-14-2024, 02: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: 40,579
Karma: 157444380
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 offline   Reply With Quote
Advert
Old 03-14-2024, 04: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,225
Karma: 19000635
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/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 offline   Reply With Quote
Old 03-14-2024, 06: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: 40,579
Karma: 157444380
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
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, 07:48 AM   #8
swepub
Swepub
swepub began at the beginning.
 
Posts: 23
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 10:00 AM
Predefined regex for Regex-function sherman Editor 3 01-19-2020 06:32 AM
Q: Regex Find and Replace delete surrounding tags hidden.platypus Editor 14 06-17-2015 12:16 AM
python regex: delete text in preprocessing sws Recipes 0 01-11-2013 10:01 AM
Delete files in PC not equal to delete in Sony reader 505 sheilalayoli Sony Reader 5 07-12-2009 04:13 PM


All times are GMT -4. The time now is 10:42 AM.


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