![]() |
#1 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Dec 2010
Device: Kindle Scribe
|
Regex expression to replace certain spaces with nonbreaking spaces
Hi,
I would like to automatically find and replace the spaces in "T. S. Eliot", "D. H. Lawrence", "F. R. Leavis" and similarly patterned names with non-breaking spaces. I've tried: Find: Code:
[A-Z]\.\s Code:
\g<0>&#nbsp; |
![]() |
![]() |
![]() |
#2 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,306
Karma: 13057279
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
Quote:
- - - Side Note: If you wanted even more fantastic regex tips/tricks, see my posts a few months ago in: I linked to a ton of the previous topics + step-by-step breakdowns of helpful regular expressions. - - - And may I ask why you're trying to use NBSPs in your ebooks? Is there any specific reason or issue you were trying to solve? Last edited by Tex2002ans; 12-10-2022 at 02:18 AM. |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 3
Karma: 10
Join Date: Dec 2010
Device: Kindle Scribe
|
Thank you very much for pointing me to the right thread! I'll go with:
Find: Code:
([A-Z])\. ([A-Z])\. ([A-Z]) Code:
\1.\xA0\2.\xA0\3 That seems to suit me perfectly. Since you asked, I just don't like line breaks after the first or second initial when I read a book on my Kindle. |
![]() |
![]() |
![]() |
#4 |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 44,641
Karma: 168431739
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
For what it's worth,   is the same as & #160; and . HTML5 which the basis for Epub3 CSS deprecated all but the big 5 named entities so you would have to explicitly define any named entities other than ", ', &, <, >.
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Writing spaces for regex | roger64 | Sigil | 10 | 12-05-2017 09:26 PM |
How to make regex to replace 2 spaces between words, with one space? | crankypants | Sigil | 4 | 10-29-2015 11:51 AM |
regex - issue with spaces? | cybmole | Editor | 43 | 12-31-2013 12:49 PM |
Regex Find and Replace - Spaces | essayhead | Sigil | 2 | 08-10-2012 07:41 PM |
Regular Expression: does not replace with spaces | murphycc | Conversion | 3 | 02-11-2012 01:31 PM |