Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Formats > Workshop

Notices

Reply
 
Thread Tools Search this Thread
Old 11-06-2011, 07:27 AM   #1
virtual_ink
Zealot
virtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheese
 
virtual_ink's Avatar
 
Posts: 107
Karma: 1000
Join Date: Sep 2010
Location: Melbourne, Australia
Device: iPad2, Kindle
GREP search term help

Until I learn GREP, could someone please help put the following into a GREP search for me?

I want to find:
<h2 id="toc_marker-1-1" class="chapter"><span class="bold"><a id="Introduction"/>Introduction</span></h2>

And change it to:
<a id="Introduction"/><h2 id="toc_marker-1-1" class="chapter"><span class="bold">Introduction</span></h2>

NB: The id="toc_marker-1-1" number will change, from 1-1 through to say 10-10. And the chapter title within the "<a id="Introduction"/>Introduction</span></h2>" will also change to whatever the chapter name is.
virtual_ink is offline   Reply With Quote
Old 11-07-2011, 10:58 AM   #2
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,725
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
I'm not very good at regular expressions, but the following quick and dirty search and replace expressions should work:

Seach for:

Code:
<h2 id="([^"]+)" class="chapter"><span class="bold"><a id="([^"]+)"/>([^<]+)</span></h2>

Replace with:

Code:
<a id="\2"/><h2 id="\1" class="chapter"><span class="bold">\3</span></h2>
Doitsu is offline   Reply With Quote
Advert
Old 11-08-2011, 12:57 AM   #3
virtual_ink
Zealot
virtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheesevirtual_ink can extract oil from cheese
 
virtual_ink's Avatar
 
Posts: 107
Karma: 1000
Join Date: Sep 2010
Location: Melbourne, Australia
Device: iPad2, Kindle
This works a treat - thank you so much!
virtual_ink is offline   Reply With Quote
Reply

Tags
grep, mobi conversion, regex, regexp, rexeg


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Another Grep Question Fabe Sigil 4 12-13-2010 04:51 PM
Grep Find & Replace Fabe Sigil 3 12-06-2010 12:00 PM
using the Calibre GREP to format chapters in RTFs raingod Amazon Kindle 1 10-08-2010 02:52 AM
The Dark Energy Term Robertjaisonblac Writers' Corner 0 12-06-2009 10:26 AM
Google Book Search to search full-text books online Bob Russell Deals and Resources (No Self-Promotion or Affiliate Links) 1 08-19-2006 12:13 PM


All times are GMT -4. The time now is 10:04 PM.


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