Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 02-06-2022, 02:08 PM   #1
JeanM
Member
JeanM began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Jan 2022
Location: французская страна басков
Device: BooX Poke3
Thumbs down search-replace with regular expressions

Hi,
I want (in French) to add a non-breaking space in front of the ";" or the "!" for example, in the search box I put [a-z]; or [a-z]! but what should I put in the replace box so that I don't lose the last character of the sentence? … of the sentence and not necessarily end of paragraph.

Bonsoir,
Je souhaite (en français) ajouter un espace insécable devant les ";" ou les "!" par exemple, dans recherche je mets [a-z]; ou [a-z]! mais que dois-je mettre dans remplacer pour ne pas perdre le dernier caractère de la phrase*?… pas nécessairement fin d'alinéa.

Merci google pour la traduction en anglais
JeanM is offline   Reply With Quote
Old 02-06-2022, 02:19 PM   #2
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,190
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
I'd suggest searching for ([a-z]); or ([a-z])! and using \1&#1 6 0 ;; or \1&#1 6 0 ;! as the replace. Alternately, you could use & 8 2 3 9 ; (a narrow non-breaking space) if your font supports that glyph.

Remove the spaces between the digits of 160 or 8239 and the ; (needed to keep the characters visible).

Last edited by DNSB; 02-06-2022 at 02:26 PM. Reason: Edited to make the nbsp and nnbsp space characters stay visible
DNSB is offline   Reply With Quote
Advert
Old 02-06-2022, 04:15 PM   #3
Sarmat89
Fanatic
Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.Sarmat89 ought to be getting tired of karma fortunes by now.
 
Posts: 516
Karma: 2268308
Join Date: Nov 2015
Device: none
To be able to put " !" in the replace box, use
Code:
(?<=\p{Ll})!
Sarmat89 is offline   Reply With Quote
Old 02-06-2022, 05:29 PM   #4
JeanM
Member
JeanM began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Jan 2022
Location: французская страна басков
Device: BooX Poke3
Code:
calibre, version 5.34.0
ERREUR : Exception non gérée: <b>IndexError</b>:no such group

calibre 5.34  embedded-python: True is64bit: True
Linux-5.13.0-28-generic-x86_64-with-glibc2.2.5 Linux ('64bit', 'ELF')
('Linux', '5.13.0-28-generic', '#31~20.04.1-Ubuntu SMP Wed Jan 19 14:08:10 UTC 2022')
Python 3.8.5
Interface language: fr
Successfully initialized third party plugins: Standard Ebooks (1, 0, 0)
Traceback (most recent call last):
  File "calibre/gui2/tweak_book/boss.py", line 1116, in search
  File "calibre/gui2/tweak_book/search.py", line 1561, in run_search
  File "calibre/gui2/tweak_book/search.py", line 1468, in do_replace
  File "calibre/gui2/tweak_book/editor/widget.py", line 329, in replace
  File "calibre/gui2/tweak_book/editor/text.py", line 598, in replace
IndexError: no such group
JeanM is offline   Reply With Quote
Old 02-06-2022, 05:32 PM   #5
JeanM
Member
JeanM began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Jan 2022
Location: французская страна басков
Device: BooX Poke3
DNSB
Code:
calibre, version 5.34.0
ERREUR : Exception non gérée: <b>IndexError</b>:no such group

calibre 5.34  embedded-python: True is64bit: True
Linux-5.13.0-28-generic-x86_64-with-glibc2.2.5 Linux ('64bit', 'ELF')
('Linux', '5.13.0-28-generic', '#31~20.04.1-Ubuntu SMP Wed Jan 19 14:08:10 UTC 2022')
Python 3.8.5
Interface language: fr
Successfully initialized third party plugins: Standard Ebooks (1, 0, 0)
Traceback (most recent call last):
  File "calibre/gui2/tweak_book/boss.py", line 1116, in search
  File "calibre/gui2/tweak_book/search.py", line 1561, in run_search
  File "calibre/gui2/tweak_book/search.py", line 1468, in do_replace
  File "calibre/gui2/tweak_book/editor/widget.py", line 329, in replace
  File "calibre/gui2/tweak_book/editor/text.py", line 598, in replace
IndexError: no such group
JeanM is offline   Reply With Quote
Advert
Old 02-06-2022, 07:22 PM   #6
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
I would use:

Code:
([a-z])([;!])
or

Code:
(\w)([;!])
The latter allows mixed case. And I think accented characters.

With the replace being:

Code:
\1 6 0 ;\2
or

Code:
\1& 8 2 3 9 ;\2
With, as @DNSB said, the extra spaces inside the number removed. If I don't put them in, the browser or site interprets the code. Or you could cut-and-paste the space you want to put there.

Last edited by davidfor; 02-06-2022 at 07:27 PM. Reason: Hit the wrong button.
davidfor is offline   Reply With Quote
Old 02-07-2022, 04:14 AM   #7
JeanM
Member
JeanM began at the beginning.
 
Posts: 17
Karma: 10
Join Date: Jan 2022
Location: французская страна басков
Device: BooX Poke3
Thank you very much, it works!
JeanM is offline   Reply With Quote
Old 02-07-2022, 04:35 AM   #8
un_pogaz
Chalut o/
un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.un_pogaz understands the importance of being earnest.
 
un_pogaz's Avatar
 
Posts: 439
Karma: 145424
Join Date: Dec 2017
Device: Kobo
Hello comrade francophone o/
To make your life easier in the future, when you add new books for example, I recommend the plugin Mass Search/Replace which allows allows to launch quickly and easily in 1 click a Search/Replace operation.
Here is my list of operations for non-breaking spaces (and a little more).
To add it in your plugin : right click > Import > In the window, select the file "unbreakable space.owip.zip" on your PC

Français:
Bonjour camarade francophone o/
Pour vous faciliter la vie a l'avenir, quand vous ajouter de nouveau livres par exemple, je vous recommande le plugin Mass Search/Replace qui vous permet de lancer rapidement et facilement en 1 clique une opération Search/Replace.
Voici ci joint ma liste d'opération pour les espace insécable (et un peu plus).
Pour l'ajouter dans votre plugin : clique droite > Importer > Dans la fenêtre, sélectionner le fichier "espace insécable.owip.zip" sur votre PC

EDIT: Oh, it's for the editor, crap
Attached Files
File Type: zip espace insécable.owip.zip (12.4 KB, 104 views)

Last edited by un_pogaz; 02-07-2022 at 07:09 AM.
un_pogaz is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bulk Edit Search & Replace expressions? OldLincoln Library Management 6 01-14-2017 06:00 PM
Regular Expressions search in Book Viewer fncll Library Management 5 03-04-2016 04:52 PM
Regular expressions in the replace field markallanson Editor 5 09-06-2014 12:44 PM
Help with regular expression search/replace bfollowell Sigil 12 06-20-2013 07:36 PM
Search & Replace - Regular expression oldbwl Calibre 2 01-09-2011 09:33 AM


All times are GMT -4. The time now is 08:49 PM.


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