Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > Non-English Discussions > Deutsches Forum > Software

Notices

Reply
 
Thread Tools Search this Thread
Old 03-15-2017, 02:14 AM   #1
calibre-ak-4711
Junior Member
calibre-ak-4711 knows what time it iscalibre-ak-4711 knows what time it iscalibre-ak-4711 knows what time it iscalibre-ak-4711 knows what time it iscalibre-ak-4711 knows what time it iscalibre-ak-4711 knows what time it iscalibre-ak-4711 knows what time it iscalibre-ak-4711 knows what time it iscalibre-ak-4711 knows what time it iscalibre-ak-4711 knows what time it iscalibre-ak-4711 knows what time it is
 
Posts: 4
Karma: 2480
Join Date: May 2015
Device: none
Rechenfunktion mit RegEx

Hallo Freunde,
ich brauche eure Hilfe: Ich bearbeite mit dem Sigil-Editor ein epub mit ca. 3000 Fußnoten.

Die Fußnoten-Nummer muß ich umsetzen, dabei muß zur gefundenen Fußnote z.B. immer 47 addiert werden. Also aus 212 + 47 = 253.

Hier das vereinfachte Beispiel:

Suche: (<sup>)(\d+)(</sup>)
Ersetze: <a href="Anm.xhtml#\2+47"><sup id="n\2+47">[\2+47]</sup></a>
Ergebnis: <a href="Anm.xhtml#253"><sup id="n253">[253]</sup></a>

Mit RegEx ist das nicht möglich, allerdings bin ich im Netz auf die Option:
Function Mode for Search & Replace in the Editor des neuen internen Calibre-Editors gestoßen. Hier kann ein RegEx-Begriff durch eine Funktion erweitert werden unter Verwendung von Python.

Da ich nie mit Python programmiert habe und mit 72 Jahren warscheinlich auch nicht mehr die Zeit habe um es zu erlernen, bitte ich euch, mir bei der Lösung meines Problems zu helfen.

MfG Andreas

Die Lösung:

Simple math for Regex
The following Regex-Function will add 47 to any number between <sup> and </sup>. You can then use normal Regex to make any other changes that you desire.

In the Find box put "<sup>(\d+)</sup>" without the quotes.

In the Function box put "Add numbers" again without the quotes.

The code required for "Add numbers" is as follows:

import regex
from calibre import replace_entities
from calibre import prepare_string_for_xml

def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):

return ('<sup>' + str(47 + int(match.group(1))) + '</sup>')

MfG
Andreas

Last edited by calibre-ak-4711; 03-17-2017 at 05:59 AM.
calibre-ak-4711 is offline   Reply With Quote
Old 03-17-2017, 05:36 PM   #2
nhedgehog
Addict
nhedgehog ought to be getting tired of karma fortunes by now.nhedgehog ought to be getting tired of karma fortunes by now.nhedgehog ought to be getting tired of karma fortunes by now.nhedgehog ought to be getting tired of karma fortunes by now.nhedgehog ought to be getting tired of karma fortunes by now.nhedgehog ought to be getting tired of karma fortunes by now.nhedgehog ought to be getting tired of karma fortunes by now.nhedgehog ought to be getting tired of karma fortunes by now.nhedgehog ought to be getting tired of karma fortunes by now.nhedgehog ought to be getting tired of karma fortunes by now.nhedgehog ought to be getting tired of karma fortunes by now.
 
Posts: 331
Karma: 381638
Join Date: Sep 2013
Device: EnergySistemEreaderPro, Nook STG, Pocketbook 622, Bookeen Cybooks ...
Sehr interessant, danke fürs Teilen.
nhedgehog is offline   Reply With Quote
Old 04-12-2017, 03:48 AM   #3
Martina Schein
eBook-Reader-Fan
Martina Schein ought to be getting tired of karma fortunes by now.Martina Schein ought to be getting tired of karma fortunes by now.Martina Schein ought to be getting tired of karma fortunes by now.Martina Schein ought to be getting tired of karma fortunes by now.Martina Schein ought to be getting tired of karma fortunes by now.Martina Schein ought to be getting tired of karma fortunes by now.Martina Schein ought to be getting tired of karma fortunes by now.Martina Schein ought to be getting tired of karma fortunes by now.Martina Schein ought to be getting tired of karma fortunes by now.Martina Schein ought to be getting tired of karma fortunes by now.Martina Schein ought to be getting tired of karma fortunes by now.
 
Martina Schein's Avatar
 
Posts: 148
Karma: 426636
Join Date: Sep 2012
Location: Saarbruecken / DE
Device: Kobo Aura H2O
Dass man mit RegEx rechnen kann, wusste ich bisher ebenfalls nicht. Habe mir die Lösung gleich mal in meinem Notizbuch abgespeichert.

Danke schön für die Info.
Martina Schein is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Rechenfunktion mit RegEx calibre-ak-4711 Editor 5 03-15-2017 05:44 PM
Regex help please FrostWolf Library Management 2 09-23-2014 11:50 PM
Regex? weberr Editor 3 05-12-2014 09:06 PM
Sync mit Handy etc. auch mit Nicht-Amazon-Büchern möglich! Wurstbrot Amazon Kindle 14 03-28-2012 09:29 AM
360 mit 15.3: Ansicht der ganzen Seite mit Zoom-Rahmen mh445 PocketBook 0 01-03-2011 04:53 PM


All times are GMT -4. The time now is 09:48 PM.


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