Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 05-09-2011, 02:34 AM   #1
huebi
Zealot
huebi , Klaatu Barada Niktu!huebi , Klaatu Barada Niktu!huebi , Klaatu Barada Niktu!huebi , Klaatu Barada Niktu!huebi , Klaatu Barada Niktu!huebi , Klaatu Barada Niktu!huebi , Klaatu Barada Niktu!huebi , Klaatu Barada Niktu!huebi , Klaatu Barada Niktu!huebi , Klaatu Barada Niktu!huebi , Klaatu Barada Niktu!
 
Posts: 121
Karma: 5070
Join Date: Dec 2010
Device: none
Regex Problem

Hi,

how can i change


Code:
<div>
  sentence1<br />
  sentence2<br />
  sentence3<br />
  sentence4<br />
</div>
into

Code:
<p>sentence1</p>
<p>sentence2</p>
<p>sentence3</p>
<p>sentence4</p>
The Problem is there several amounts of sentences, sometimes 2, sometimes 3, sometimes more. Is there a way to do that with a regex? There are more then 500 div-sections, so doing that manually is a pain. A workaround might be doing it with 2, then 3, then 4 and so speratly.

thx in advance
huebi is offline   Reply With Quote
Old 05-09-2011, 07:06 AM   #2
Perkin
Guru
Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.
 
Perkin's Avatar
 
Posts: 657
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD, iPad (Marvin)
Search for
Quote:
<br />
Replace with
Quote:
</p><p>
Search for
Quote:
<div>
Replace with
Quote:
<p>
Search for
Quote:
</div>
Replace with
Quote:
</p>
You'll get a blank <p></p>, but they'll be easier to deal with, you could even do a s&r for them.
Perkin is offline   Reply With Quote
Advert
Old 05-09-2011, 09:42 AM   #3
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,288
Karma: 57979022
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by huebi View Post
Hi,

how can i change


Code:
<div>
  sentence1<br />
  sentence2<br />
  sentence3<br />
  sentence4<br />
</div>
into

Code:
<p>sentence1</p>
<p>sentence2</p>
<p>sentence3</p>
<p>sentence4</p>
The Problem is there several amounts of sentences, sometimes 2, sometimes 3, sometimes more. Is there a way to do that with a regex? There are more then 500 div-sections, so doing that manually is a pain. A workaround might be doing it with 2, then 3, then 4 and so speratly.

thx in advance
I would do the Div first
<div>(.+)<br />\s+</div>

<p>\1</p>

now

replace the:

<br />

with
</p> <p>

Tidy will clean the code view after switching to BV
choosing the best order, leaves the least touch-up

Last edited by theducks; 05-09-2011 at 09:44 AM. Reason: revised
theducks is online now   Reply With Quote
Old 05-10-2011, 04:32 AM   #4
cybmole
Wizard
cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.cybmole ought to be getting tired of karma fortunes by now.
 
Posts: 3,720
Karma: 1759970
Join Date: Sep 2010
Device: none
i can confirm that will work - I've patched up books which were all <div> & no <p> using the above approach.

i didn't bother to find/replace the trailing </div> tags as tidy took care of that for me.
cybmole is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Regex Faster Sigil 2 04-24-2011 09:08 PM
Regex Question Archon Conversion 11 02-05-2011 10:13 AM
What a regex is Worldwalker Calibre 20 05-10-2010 05:51 AM
Help with a regex A.T.E. Calibre 1 04-05-2010 07:50 AM
Regex help... Bobthebass Workshop 6 04-26-2009 03:54 PM


All times are GMT -4. The time now is 08:14 PM.


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