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 Today, 09:20 AM   #1
peach
Junior Member
peach began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2026
Device: xteink x3
need help with regex problem

i love using the e-reader xteink because how small and light it is. however it doesn't recognize as many font types as other e-readers like kindle or kobo so for some time already i've been using the regex option in calibre to replace the cursive text from <span class="italic">.*?</span> into <i>\1</i> but for whatever reason when i try to replace it now i get an error window saying IndexError:no such group

i've been searching how to fix this problem or an alternative i can use instead of \1 but can't find anything so i'm hoping someone here can help
peach is offline   Reply With Quote
Old Today, 09:25 AM   #2
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: 85,975
Karma: 154365289
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
Quote:
Originally Posted by peach View Post
i love using the e-reader xteink because how small and light it is. however it doesn't recognize as many font types as other e-readers like kindle or kobo so for some time already i've been using the regex option in calibre to replace the cursive text from <span class="italic">.*?</span> into <i>\1</i> but for whatever reason when i try to replace it now i get an error window saying IndexError:no such group

i've been searching how to fix this problem or an alternative i can use instead of \1 but can't find anything so i'm hoping someone here can help
The code you want is...

Search: <span class="italic">(.*?)</span>
Replace: <i>\1</i>

An easier way to do it because spans like this can use different class names, use Otter's Editing Toolbag. It's an editor plugin that's very handy/useful. It easily lets you do what are are trying to do and more.

Last edited by JSWolf; Today at 09:48 AM.
JSWolf is offline   Reply With Quote
Advert
Old Today, 09:50 AM   #3
enuddleyarbl
Guru
enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.enuddleyarbl ought to be getting tired of karma fortunes by now.
 
enuddleyarbl's Avatar
 
Posts: 960
Karma: 2111023
Join Date: Sep 2013
Device: Kobo Sage
Quote:
Originally Posted by peach View Post
... from <span class="italic">.*?</span> into <i>\1</i> but for whatever reason when i try to replace it now i get an error window saying IndexError:no such group...
Purely on the regex, if the initial search string is exactly what you're using, then you are, in fact, missing the group. You need to surround the .*? with parenthesis to define the group:

Code:
<span class="italic">(.*?)</span>
EDIT: Ninjad by 2 minutes.

Last edited by enuddleyarbl; Today at 09:54 AM.
enuddleyarbl is online now   Reply With Quote
Old Today, 11:13 AM   #4
peach
Junior Member
peach began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2026
Device: xteink x3
Quote:
Originally Posted by JSWolf View Post
The code you want is...

Search: <span class="italic">(.*?)</span>
Replace: <i>\1</i>

An easier way to do it because spans like this can use different class names, use Otter's Editing Toolbag. It's an editor plugin that's very handy/useful. It easily lets you do what are are trying to do and more.
Quote:
Originally Posted by enuddleyarbl View Post
Purely on the regex, if the initial search string is exactly what you're using, then you are, in fact, missing the group. You need to surround the .*? with parenthesis to define the group:

Code:
<span class="italic">(.*?)</span>
EDIT: Ninjad by 2 minutes.
thank you very much to both!

i didn't even think there was something wrong with the search code because the search itself was working fine and i was getting the error message when i was trying to replace it but you're absolutely right so thanks again
peach is offline   Reply With Quote
Old Today, 04:30 PM   #5
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: 32,075
Karma: 65709392
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
the \1 says put the capture group 1 in this place.
A capture group is indicated by ( ). You can have more than 1. They are numbered in order they are used.
Code:
 search: (new word 2) will be after (new word 1)
Replace: \2 is now correctly ordered \2
Note: you can include literals (characters) in addition to the captured values
theducks is offline   Reply With Quote
Advert
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with .* in regex search jwes Sigil 11 06-24-2025 06:32 PM
Odd regex problem jwes Sigil 5 11-17-2023 09:27 PM
Regex problem John2011 Sigil 8 01-21-2014 03:12 AM
Regex F&R problem? Jabby Sigil 6 06-12-2012 05:18 AM
Regex Problem huebi Sigil 3 05-10-2011 05:32 AM


All times are GMT -4. The time now is 06:15 PM.


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