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-10-2014, 01:11 PM   #1
Alt68er
Member
Alt68er began at the beginning.
 
Posts: 20
Karma: 10
Join Date: Dec 2013
Device: Pocketbook touch lux (623)
regex search/replace - how to?

Hi all,

I have a lot of weeklies which I want to edit and make them formatted equally. They all have chapters with a chapter-number and with 0 up to 3 sub-lines. Here is an example:

Code:
<body>
  <p>&nbsp;</p>

  <p>1.</p>

  <p>&nbsp;</p>

  <p>Line One</p>

  <p>&nbsp;</p>

  <p>Chapter one. Chapter one. Chapter one. Chapter one. Chapter one. Chapter one. Chapter one. Chapter one. Chapter one. Chapter one. Chapter one. Chapter one. Chapter one. Chapter one. Chapter one. Chapter one.</p>

  <p>Chapter one para two.</p>

  <p>&nbsp;</p>

  <p>2.</p>

  <p>&nbsp;</p>

  <p>Line One</p>

  <p>Line two</p>

  <p>&nbsp;</p>

  <p>Chapter two. Chapter two. Chapter two. Chapter two. Chapter two. Chapter two. Chapter two. Chapter two. Chapter two. Chapter two. Chapter two. Chapter two. Chapter two. Chapter two. Chapter two. Chapter two.</p>

  <p>Chapter two para one.</p>

  <p>&nbsp;</p>

  <p>3.</p>

  <p>&nbsp;</p>

  <p>Line One</p>

  <p>Line two</p>

  <p>Line three</p>

  <p>&nbsp;</p>

  <p>Chapter three. Chapter three. Chapter three. Chapter three. Chapter three. Chapter three. Chapter three. Chapter three. Chapter three. Chapter three. Chapter three. Chapter three. Chapter three. Chapter three. Chapter three. Chapter three.</p>

  <p>Chapter three para two.</p>

  <p>&nbsp;</p>

  <p>4.</p>

  <p>&nbsp;</p>

  <p>Line One</p>

  <p>Line two</p>

  <p>Line three</p>

  <p>Line four</p>

  <p>&nbsp;</p>

  <p>Chapter four. Chapter four. Chapter four. Chapter four. Chapter four. Chapter four. Chapter four. Chapter four. Chapter four. Chapter four. Chapter four. Chapter four. Chapter four. Chapter four. Chapter four. Chapter four.</p>

  <p>Chapter four para two.</p>

  <p>&nbsp;</p>
</body>
The chapter number plus the sub-lines (if there) shall be replaced by

Code:
<hr class="sigilChapterBreak" /> <h1 class="h11">\1</h1>
<p class="p0"><span class="t4">\2<br/>\3</span></p>
In this example the replace-string is for a chapter-number plus 1 subline only.

Is there a way to make a search finding the chapter-number plus the existing number of sub-lines and replace them according the above example?

If not please help me in creating a search that finds not more than the FIRST &nbsp;.

1000 thanks in advance.

Peter
Alt68er is offline   Reply With Quote
Old 03-11-2014, 08:53 PM   #2
eschwartz
Ex-Helpdesk Junkie
eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.eschwartz ought to be getting tired of karma fortunes by now.
 
eschwartz's Avatar
 
Posts: 19,421
Karma: 85397180
Join Date: Nov 2012
Location: The Beaten Path, USA, Roundworld, This Side of Infinity
Device: Kindle Touch fw5.3.7 (Wifi only)
".*(?!&nbsp;).&nbsp;" will match all characters up to and including the first match for "&nbsp;" using a negative lookahead.

"(?!string)" is not a capture group!
eschwartz is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
search/replace multiline regex Alt68er Sigil 4 02-01-2014 09:40 AM
Regex search and replace dwlamb Sigil 6 04-12-2013 02:34 PM
regex search/replace Sharlene Sigil 10 01-28-2012 04:14 AM
Search & Replace/Regex help!! millertime13 Conversion 4 07-22-2011 02:40 AM
need regex help search and replace schuster Calibre 4 01-10-2011 09:00 AM


All times are GMT -4. The time now is 08:46 AM.


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