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

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 01-09-2021, 08:47 AM   #1
CarlosJavier
Junior Member
CarlosJavier began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Jan 2021
Device: Kindle
Help - Regex code to add parameter to a tag.

Good morning,
I am new in caliber, and when I did my first conversion from azw3 to epub,
the text appears in positions that do not correspond,

then investigating a little more in the code I have verified that it is missing to add a parameter to a label.

Code:
<span class="word si fs5" style="left: 518px; top: 613px; width: 165px; ">COU</span>
<span class="word si fs5" style="left: 697px; top: 613px; width: 149px; ">RSE</span>
<span class="word si fs6" style="left: 891px; top: 613px; width: 219px; ">BOOK</span>
What I need is to add the word "pos" after "word si", the result should look like this.

Code:
<span class="word si pos fs5" style="left: 518px; top: 613px; width: 165px; ">COU</span>
<span class="word si pos fs5" style="left: 697px; top: 613px; width: 149px; ">RSE</span>
<span class="word si pos fs6" style="left: 891px; top: 613px; width: 219px; ">BOOK</span>
In this way the absolute position of the left and top scrolling parameters will be respected, and the text will be scrolled to the correct position.

I started reading the regex examples, and the only thing I could do was this,
but I don't achieve the desired result.

search : word si([^f]+)
replace : \1pos

somebody please help me.

Greetings.
CarlosJavier is offline   Reply With Quote
Old 01-09-2021, 02:24 PM   #2
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: 450
Karma: 3886916
Join Date: May 2013
Location: Ontario, Canada
Device: Kindle KB, Oasis, Pop_Os!, Kobo Forma
Assuming a standard space character between si and fs, I would just try a regular non-regex search:

Search si fs
replace si pos fs

The chance of other text getting caught in error looks pretty low with that combination. But that looks like it might be a fixed-layout book...good luck.
retiredbiker is offline   Reply With Quote
Old 01-09-2021, 04:28 PM   #3
deback
Book E d i t o r
deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.deback ought to be getting tired of karma fortunes by now.
 
Posts: 432
Karma: 288184
Join Date: May 2015
Device: Laptop
Retiredbiker's solution should work. Here's a Regex solution:

Find: "word si fs([\d]+)"

Replace: "word si pos fs\1"
deback is offline   Reply With Quote
Old 01-09-2021, 04:36 PM   #4
JSWolf
Resident Curmudgeon
JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.JSWolf ought to be getting tired of karma fortunes by now.
 
JSWolf's Avatar
 
Posts: 79,758
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
This is a regular search solution that will work 100%.

Search: <span class="word si fs5"
Replace: <span class="word si pos fs5"
JSWolf is offline   Reply With Quote
Old 01-09-2021, 08:06 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: 46,220
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
Quote:
Originally Posted by JSWolf View Post
This is a regular search solution that will work 100%.

Search: <span class="word si fs5"
Replace: <span class="word si pos fs5"
Umm... Jon, did you look at all three lines of the sample supplied? Note the bolded item in the third line. That is where @deback's regex is superior.

Code:
<span class="word si fs5" style="left: 518px; top: 613px; width: 165px; ">COU</span>
<span class="word si fs5" style="left: 697px; top: 613px; width: 149px; ">RSE</span>
<span class="word si fs6" style="left: 891px; top: 613px; width: 219px; ">BOOK</span>
DNSB 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
Regex Beginning and End of Tag d351r3d Sigil 7 06-08-2020 11:40 PM
Regex: grabbing <h3><span> tag group meghane_e Editor 8 03-28-2019 04:33 PM
Why does the [code] tag add an empty line at the end? DSpider Feedback 3 06-01-2012 07:34 AM
restricting regex to single lines of code? ElMiko Sigil 14 01-28-2012 04:39 PM
Help with RegEx - add Year as Tag item puterdude Library Management 0 01-20-2012 03:06 PM


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


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