![]() |
#1 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 67
Karma: 136594
Join Date: Jan 2013
Location: Hong Kong
Device: Kindle DX, Paperwhite, Paperwhite II, and Voyage
|
Regex question
This may not even be possible, but you don't know until you ask, right?
I am trying to capitalise the first word of every chapter. Easy enough to do manually (just highlight the word and hit the uppercase button, or the keyboard shortcut). I was wondering if it was possible to do via "Find and Replace". The "find" is no problem, its the "replace" I am struggling with. Possible, or no? Phil |
![]() |
![]() |
![]() |
#2 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,680
Karma: 23983815
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
For specific examples, see this old post of mine. |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 875
Karma: 2676800
Join Date: Aug 2008
Location: Taranaki - NZ
Device: Kobo Aura H2O, Kobo Forma
|
It is possible. See here. Specifically, note: Perl String Features in Regular Expressions and Replacement Texts, although Sigil notation is a little different to Perl.
A simple example. Suppose you had the text: Code:
<h2>chapter two</h2> Code:
Search = <h2>(.+?)</h2> Replace = <h2>\u\1</h2> Code:
<h2>Chapter one</h2> Hope this helps. |
![]() |
![]() |
![]() |
#4 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 878
Karma: 2457540
Join Date: Nov 2011
Device: none
|
Is this a client's requirement? If not, you might reconsider. This sort of things, like drop capitals, can be attractively decorative on paper, but often looks merely odd on an e-reader screen.
|
![]() |
![]() |
![]() |
#5 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,680
Karma: 23983815
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
You could for example use ::first-letter to apply drop caps formatting to the first letter of a paragraph or ::first-line to apply small caps to the first line of a paragraph. |
|
![]() |
![]() |
Advert | |
|
![]() |
#6 | |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 878
Karma: 2457540
Join Date: Nov 2011
Device: none
|
Quote:
|
|
![]() |
![]() |
![]() |
#7 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 67
Karma: 136594
Join Date: Jan 2013
Location: Hong Kong
Device: Kindle DX, Paperwhite, Paperwhite II, and Voyage
|
Thanks all. I had seen the \U\E somewhere, but couldn't work out how to get it to work in the "replace" box.
That works perfectly - and Doitsu, thanks for the link to your earlier post. I DID search, but I didn't see that one. Appreciate all your help. Wombat. Appreciate your thoughts. I am capitalising the first word (unless it is a name, in which case it is the whole name), with the first letter full size and the subsequent ones about 80% small-caps. The content, and hence the "feel" I am trying to create, of the book is of one which could have been published at the turn of the last century....to my mind, this achieves this relatively simply and "unfussily". I agree with you though that drop caps (although I have used them) are often a bit much..... Phil Last edited by Hendrixxxxxxxx; 01-02-2016 at 08:27 AM. Reason: wordsmithing |
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,343
Karma: 203719646
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
That's just one opinion (unsuccessfully dressed up like a fact). Anybody who gets fussed over a successfully displayed single raised/dropped capital (letter or word) is just looking for things to get fussed over (and can probably easily un-fuss it themselves anyway). There's still a large contingent of readers (the human kind) who actually enjoy a little tasteful artistic expression where ebook layout is concerned. I welcome your "pouring-text-into-a-bucket" analogy with regard to flowing text and "pages," but don't at all welcome it when it gets used as an excuse to homogenize the formatting of all books into one archetypal formula. Blecch! Hope it never comes to pass.
|
![]() |
![]() |
![]() |
#9 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,889
Karma: 59840450
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
|
![]() |
![]() |
![]() |
#10 | |
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,503
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Phil, if you are planning on selling that ePUB on B&N, or your client is, I can absolutely promise you that trying to do a full-size cap with smallcaps follow-on lettering will cause you all sorts of agita on a B&N device. If you use several spans (IOW, more than one) on the first line of a paragraph, in a B&N ePUB, it will either: a) break bizarrely, with strange world hyphenation, mid-word (think...D-og), or b) the first letter will stay where it is supposed to, and the smallcaps remainder will, I kid thee not, align, one letter at a time, vertically on the page, against the left-margin edge. The double-span use breaks the hyphenation rendering engine, and you get weird, weird, WEIRD results. Not one of them works worth a damn. The Nook rendering engine purely HATES what you are trying to do. If you searched hard enough, you'll find a really old post of mine--what, guys, anyone remember? 2010 or 11? Maybe even 09?--on this very topic. It's remotely possible that they've fixed it, but whatever you do, test test and test again, if you are planning on Nook distro. Offered FWIW. ETA: That thread was here, and I repeated the same issue in 2014, so, as of 2014, it was not fixed: https://www.mobileread.com/forums/sho...d.php?t=232395 Hitch Last edited by Hitch; 01-05-2016 at 08:18 PM. Reason: Added the thread link and comment. |
|
![]() |
![]() |
![]() |
#11 | |
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,503
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
Quote:
Hitch |
|
![]() |
![]() |
![]() |
#12 |
Banned
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 272
Karma: 1224588
Join Date: Sep 2014
Device: Sony PRS 650
|
|
![]() |
![]() |
![]() |
#13 |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 67
Karma: 136594
Join Date: Jan 2013
Location: Hong Kong
Device: Kindle DX, Paperwhite, Paperwhite II, and Voyage
|
Thanks Hitch. I'll have a look into your past ('09? How old ARE you?
![]() In any event, not selling anything anywhere - its just me trying to learn. Last edited by Hendrixxxxxxxx; 01-06-2016 at 07:48 AM. |
![]() |
![]() |
![]() |
#14 | ||
Bookmaker & Cat Slave
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 11,503
Karma: 158448243
Join Date: Apr 2010
Location: Phoenix, AZ
Device: K2, iPad, KFire, PPW, Voyage, NookColor. 2 Droid, Oasis, Boox Note2
|
![]() ![]() ![]() ![]() Quote:
Quote:
Best, Hitch |
||
![]() |
![]() |
![]() |
#15 | |
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 67
Karma: 136594
Join Date: Jan 2013
Location: Hong Kong
Device: Kindle DX, Paperwhite, Paperwhite II, and Voyage
|
Quote:
Interesting ADE seems to handle it OK. Must be just a Nook specific thing. I don't have a Nook, so can't test it....but I don't have a Nook so nor do I need to. ![]() |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
regex question | DrChiper | Editor | 14 | 11-22-2014 04:27 AM |
RegEx question (again) | phossler | Sigil | 12 | 01-20-2013 02:37 PM |
A regex question | PatNY | Sigil | 30 | 06-03-2012 02:03 PM |
Regex question and maybe some help | crutledge | Sigil | 9 | 03-10-2011 04:37 PM |
Regex Question | Archon | Conversion | 11 | 02-05-2011 10:13 AM |