Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-10-2023, 03:09 AM   #1
aurigod
Enthusiast
aurigod began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Oct 2012
Location: Lyon [France]
Device: JuliusvonJD
Regex / Find and Replace Non Breaking Space

I want to swap some space characters and non-breaking space.
In the test the search works with \x20 (32) but not with \xa0 (160 / nbsp). Which code to use for the nbsp?
I have tried several without success.
Thanks
aurigod is offline   Reply With Quote
Old 01-10-2023, 03:29 AM   #2
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,089
Karma: 4911876
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
You could simply copy the nbsp from the text and paste it into the Find bar.
You don't need any fancy code.
Karellen is offline   Reply With Quote
Old 01-10-2023, 04:59 AM   #3
aurigod
Enthusiast
aurigod began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Oct 2012
Location: Lyon [France]
Device: JuliusvonJD
Quote:
Originally Posted by Karellen View Post
You could simply copy the nbsp from the text and paste it into the Find bar.
You don't need any fancy code.
I tried :-(
Don't work, it fetches ALL the spaces : normal et nbsp.
aurigod is offline   Reply With Quote
Old 01-10-2023, 08:45 AM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It works fine make sure the mode in the search panel is normal or regex
kovidgoyal is offline   Reply With Quote
Old 01-10-2023, 12:14 PM   #5
aurigod
Enthusiast
aurigod began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Oct 2012
Location: Lyon [France]
Device: JuliusvonJD
Sorry, I wasn't clear.
I meant the conversion tool not the editing tool.
With "Find and Replace" function.

I want to use it to turn a lot of (but not all) nbps into normal spaces.
with a function like this :
Rch = ([!\«\–\—])\xA0([!\;\:\?\!\»]) Rpl = \1\20\2

So I tried to start by finding one NBPS !
I put a picture.


Thanks for calibre.
It's great.
aurigod is offline   Reply With Quote
Old 01-13-2023, 09:06 AM   #6
aurigod
Enthusiast
aurigod began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Oct 2012
Location: Lyon [France]
Device: JuliusvonJD
It works like this in "Edit Book" or "Search & replace" of "Convert book"

([^–«—])\xa0([^!?;:»]) => \1\x20\2
and to change normal into nbps
- before ! ? ; :»
\x20([!?;:»]) => \xa0\1
- After – — «
([–«—])\x20 => \1\xa0


The code a0 of the nbps is not found in the test (all spaces are shown).

Last edited by aurigod; 01-15-2023 at 03:13 AM.
aurigod is offline   Reply With Quote
Old 01-14-2023, 01:29 AM   #7
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,843
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
https://github.com/kovidgoyal/calibr...f8d2d6181fede6
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New to regex find and replace! ksimpson1986 Sigil 2 11-06-2016 11:29 AM
How to make regex to replace 2 spaces between words, with one space? crankypants Sigil 4 10-29-2015 11:51 AM
regex cannot find to replace eschwartz Editor 11 02-03-2014 11:00 PM
Regex find and replace SanatyrZeo Sigil 5 10-29-2012 07:03 AM
RegEx find and replace iblesq Sigil 1 01-10-2011 09:26 PM


All times are GMT -4. The time now is 12:50 PM.


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