10-19-2021, 05:02 PM | #46 |
Morlock
Posts: 34
Karma: 2734796
Join Date: Oct 2021
Device: Kindle Paperwhite
|
|
04-02-2022, 03:10 PM | #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 | |
|
04-02-2022, 06:28 PM | #48 |
Zealot
Posts: 148
Karma: 1451628
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 02:57 PM. |
04-04-2022, 03:20 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,}(?![^<>{}]*[>}]) |
04-04-2022, 06:55 PM | #50 | |
Zealot
Posts: 148
Karma: 1451628
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 08:10 PM. Reason: adding a regex excluding currency |
|
Advert | |
|
09-12-2022, 02:34 AM | #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? |
09-12-2022, 10:33 AM | #52 | |
Well trained by Cats
Posts: 30,452
Karma: 58055868
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. |
|
09-14-2022, 03:56 AM | #53 | |
drowned in old books
Posts: 39
Karma: 62
Join Date: May 2012
Location: United States
Device: Kindle Paperwhite
|
Quote:
|
|
02-19-2023, 07:57 PM | #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?
|
02-20-2023, 03:58 PM | #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
|
02-20-2023, 04:11 PM | #56 |
Resident Curmudgeon
Posts: 76,489
Karma: 136564766
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
02-20-2023, 05:37 PM | #57 |
Member
Posts: 10
Karma: 10
Join Date: Jan 2020
Device: laptop
|
please drop the link
|
02-20-2023, 08:18 PM | #58 |
Bibliophagist
Posts: 40,595
Karma: 157444382
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.
|
02-20-2023, 09:03 PM | #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.
|
02-20-2023, 10:56 PM | #60 |
creator of calibre
Posts: 44,564
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
No there is no such function.
|
Tags |
conversion, errors, function, ocr, spelling |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
About saved searches and regex | Carpatos | Editor | 22 | 09-30-2020 11:56 PM |
Regex-Functions - getting user input | CalibUser | Editor | 8 | 09-09-2020 05:26 AM |
Difference in Manual Search and Saved Search | phossler | Editor | 4 | 10-04-2015 01:17 PM |
Help - Learning to use Regex Functions | weberr | Editor | 1 | 06-13-2015 02:59 AM |
Limit on length of saved regex? | ElMiko | Sigil | 0 | 06-30-2013 04:32 PM |