04-13-2017, 10:30 AM | #1 |
Enthusiast
Posts: 41
Karma: 10
Join Date: Mar 2008
Device: Sony PRS-T1
|
Regex help please
Hi all,
Would really appreciate some help please with regex and turning Title Case to UPPERCASE. How could I turn: <span style="font-size:80%;">Sample Text</span> to <span style="font-size:80%;">SAMPLE TEXT</span> I'm trying to have this reoccur for the first few sentences of each chapter. any help appreciated! |
04-13-2017, 12:27 PM | #2 |
A Hairy Wizard
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Search: <span style="font-size:80%;">(.*?)</span>
Replace: <span style="font-size:80%;">\U\1\E</span> Can I also add a recommendation that you try and avoid inline styles whenever possible. I would recommend using classes and css stylesheets like this: <span class="upper">Sample Text</span> with CSS: span.upper {text-transform:uppercase; font:size:.8em} There are lots of benefits to using stylesheets over inline styles! Cheers, Last edited by Turtle91; 04-13-2017 at 12:32 PM. |
04-13-2017, 01:07 PM | #3 |
Interested in the matter
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
|
|
04-13-2017, 02:19 PM | #4 |
A Hairy Wizard
Posts: 3,093
Karma: 18727053
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
The second part of your question - that you are trying to do this for the first couple of sentences for each chapter - would lead to another discussion.
I use a slightly different approach for my opening paragraph. There is a CSS method that will automatically format the first line of a paragraph without having to use those spans. That method uses what are called pseudo-elements (W3Schools link). They are very effective. However, support for them has been lacking in the older reader's apps so you haven't seen them used much. My reader app of choice supports them so I've been using them for years... and the newer apps/readers are providing more support. Here's how they work: Code:
<h2>Chapter 1</h2> <p class="first">This is the first paragraph...yada yada.</p> <p>This is a normal paragraph.</p> <p>This is another normal paragraph.</p> with CSS: p {text-indent:1.2em; margin:0; line-height:1} p.first {text-indent:0; font-size:1em; clear:both} p.first:first-letter {font-family:serif; font-size:2em; font-weight:bold; float:left; margin:-.1em .1em} p.first:first-line {font-variant:small-caps; font-size:1.15em} I also use the small-caps instead of uppercase so that I can differentiate capital letters in names, etc. Last edited by Turtle91; 04-13-2017 at 02:21 PM. |
04-15-2017, 12:22 AM | #5 |
Enthusiast
Posts: 41
Karma: 10
Join Date: Mar 2008
Device: Sony PRS-T1
|
Thanks so much for help Turtle91 and jbacelar!
Yes you guessed correctly I was trying to mimic the look of an actual book which starts off with small-caps on the first line. I would have been just content to have them all in capital letters, for some reason I don't think css small-caps works on my sony prs-t1 - not unless I use a specific small-cap font like fontin has. I tried your second method within sigil and the preview looks very nice indeed, will post back once I've tried it with the sony t1. thanks again :-) |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Regex help please | BookJunkieLI | Calibre | 3 | 07-01-2014 03:18 PM |
Regex? | weberr | Editor | 3 | 05-12-2014 09:06 PM |
Help with some regex | Chaos_Therum | Library Management | 1 | 12-28-2013 11:20 AM |
Regex help | paulfiera | Sigil | 4 | 06-14-2012 07:55 AM |
regex help please | thevoiceofcheese | Calibre | 2 | 08-01-2011 11:27 PM |