![]() |
#46 |
Morlock
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 33
Karma: 2734796
Join Date: Oct 2021
Device: Kindle Paperwhite
|
|
![]() |
![]() |
![]() |
#47 |
Member
![]() Posts: 13
Karma: 10
Join Date: Feb 2010
Device: none
|
I'm looking for a method to convert numbers that use the european comma separated format (ex. 1.000,95) to the US version (ex 1,000.95)
Is this achievable with regex or via a search function? |
![]() |
![]() |
Advert | |
|
![]() |
#48 |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 139
Karma: 1000102
Join Date: Jul 2021
Device: N/A
|
Assuming all numbers are in european format (no one in US format):
Code:
find: \d[,.\d]{2,}(?![^<>{}]*[>}]) function: def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): return match.group(0).replace('.', '§').replace(',', '.').replace('§',',') Note: all number with 3 or more positions will be catched (e.g. 1,2, or 1.2). If you want to be more selective, change "{2,} for what you want minus 1, e.g. {4,} if you want to catch starting from 5 positions (1.000 or 12,45) Note: Integers as 100 or 234000 will be catched, but they won't be transformed. Warning : numbers followed by 3 dots will be wrongly transformed : "They were 20..." will give "They were 20,,," It's wise to change them to ellipsis (…) prior to apply the conversion: (\d)\.{3} ==> \1\u2026 Last edited by lomkiri; 04-03-2022 at 01:57 PM. |
![]() |
![]() |
![]() |
#49 |
Member
![]() Posts: 13
Karma: 10
Join Date: Feb 2010
Device: none
|
Spoiler:
Thanks so much, it worked great! I ended up using Code:
find 1: (\d{1,3}[.,])+\d{1,}(?![^<>{}]*[>}]) find 2: \$(\d{1,3}[.,])+\d{1,}(?![^<>{}]*[>}]) |
![]() |
![]() |
![]() |
#50 | |
Zealot
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 139
Karma: 1000102
Join Date: Jul 2021
Device: N/A
|
Mmmh, yes, of course, I forgot this case :-/. Good you thought about it :-)
Quote:
Code:
(\$(?:\d{1,3}[.,])+)(*SKIP)(*F)|(<[^<>]*)(*SKIP)(*F)|(?:\d{1,3}[.,])+\d{1,} Code:
\$?(\d{1,3}[.,])+\d{1,}(?![^<>{}]*[>}]) function: def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): m = match.group(0) if m[0] == '$': return m else: return m.replace('.', '§').replace(',', '.').replace('§',',') Last edited by lomkiri; 04-04-2022 at 07:10 PM. Reason: adding a regex excluding currency |
|
![]() |
![]() |
Advert | |
|
![]() |
#51 |
drowned in old books
![]() Posts: 39
Karma: 62
Join Date: May 2012
Location: United States
Device: Kindle Paperwhite
|
I am making an ebook from saved and pdfunite'd pdf pages, and there are scads of things like this:
<p class="calibre1">13/72</p> <p class="calibre1">14/93</p> I want to remove. How can I? |
![]() |
![]() |
![]() |
#52 | |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,263
Karma: 57979022
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
Quote:
![]() Code:
<p class="calibre1">\d+\/\d+</p> \/ is just an escaped / (might not be needed, but dos not hurt) 'escaped' items remove their special meaning and treat them as they LOOK I left the rest to only be an 'exact match' to be a trigger. eg <p class="calibre1">The cup was 3/4 full.</p> would not match. |
|
![]() |
![]() |
![]() |
#53 | |
drowned in old books
![]() Posts: 39
Karma: 62
Join Date: May 2012
Location: United States
Device: Kindle Paperwhite
|
Quote:
|
|
![]() |
![]() |
![]() |
#54 |
Member
![]() Posts: 10
Karma: 10
Join Date: Jan 2020
Device: laptop
|
where is it possible to make an autocorrect in caliber when reading with a voice that she did not read the article (abbreviated), but the article?
|
![]() |
![]() |
![]() |
#55 |
Member
![]() Posts: 10
Karma: 10
Join Date: Jan 2020
Device: laptop
|
classical substitutions (simple replacement of one line with another), or the use of regular expressions (RegExp) and the emphasis when reading by voice and the expansion of abbreviations when reading by voice, for example vs-versus
|
![]() |
![]() |
![]() |
#56 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 75,655
Karma: 134254544
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
![]() |
![]() |
![]() |
#57 |
Member
![]() Posts: 10
Karma: 10
Join Date: Jan 2020
Device: laptop
|
please drop the link
|
![]() |
![]() |
![]() |
#58 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 38,851
Karma: 153006036
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
You would have to edit the book to make those changes such as versus for vs. As for changing emphasis, good luck with that. There are good reasons that most authors prefer using people to create audiobooks since even the best of the current automated readers are not all that great.
|
![]() |
![]() |
![]() |
#59 |
Member
![]() Posts: 10
Karma: 10
Join Date: Jan 2020
Device: laptop
|
in the Librera program on Android, there is such a function in voice reading, text-to-speech substitution is used to change the way the engine pronounces certain words, to skip certain characters when reading or to set the correct stress marks.
|
![]() |
![]() |
![]() |
#60 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,262
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No there is no such function.
|
![]() |
![]() |
![]() |
Tags |
conversion, errors, function, ocr, spelling |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
About saved searches and regex | Carpatos | Editor | 22 | 09-30-2020 10:56 PM |
Regex-Functions - getting user input | CalibUser | Editor | 8 | 09-09-2020 04:26 AM |
Difference in Manual Search and Saved Search | phossler | Editor | 4 | 10-04-2015 12:17 PM |
Help - Learning to use Regex Functions | weberr | Editor | 1 | 06-13-2015 01:59 AM |
Limit on length of saved regex? | ElMiko | Sigil | 0 | 06-30-2013 03:32 PM |