Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 12-26-2014, 07:33 PM   #1
phossler
Guru
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 897
Karma: 295106
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
RegEx Function: Title Case

Trying to use the wonderful new F&R functions to replace ALL CAPS headings

The fragment in the manual works unless there's a <br/> in the Hx tags

So if it looks like

<h1> CHAPTER 2 <br/>AWAY WE GO</h1>

it seems that the embedded <br/> causes it to not find

I cannot figure out how to modify the Find expression to handle that case

What is the modifications needed?

Thanks
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	278
Size:	124.8 KB
ID:	132976  

Last edited by phossler; 12-26-2014 at 09:28 PM.
phossler is offline   Reply With Quote
Old 12-26-2014, 10:06 PM   #2
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: 37,010
Karma: 16422171
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
(?s)<h\d>(.+?)</h\d>
kovidgoyal is online now   Reply With Quote
Advert
Old 12-27-2014, 11:06 AM   #3
phossler
Guru
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 897
Karma: 295106
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Thanks, but it doesn't seem to find the test text

Is there a setting or something I should change?
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	208
Size:	105.7 KB
ID:	133015  
phossler is offline   Reply With Quote
Old 12-27-2014, 01:01 PM   #4
jbacelar
Interested in the matter
jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.
 
jbacelar's Avatar
 
Posts: 325
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook Touch HD
Quote:
Originally Posted by phossler View Post
Thanks, but it doesn't seem to find the test text

Is there a setting or something I should change?
If you've picked the expression of Kovid by the method of copying and pasting, likely that expression in the editor has a space at the end.
And naturally finds nothing.
jbacelar is online now   Reply With Quote
Old 12-27-2014, 01:38 PM   #5
phossler
Guru
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 897
Karma: 295106
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Yep, it was a trailing space

However, the < and > in the <br/> gets replaced by named enetities

The end result seems to be they're treated like normal text instead of a tag

So I'm wondering if it's even possible to title case multiple lines

BTW, I do it that way so that the TOC has both lines as an entry:

Chapter 1 Now It All Starts
Chapter 2 And It Keeps On Going
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	204
Size:	76.3 KB
ID:	133021  
phossler is offline   Reply With Quote
Advert
Old 12-27-2014, 10:23 PM   #6
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: 37,010
Karma: 16422171
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
(?s)<h\d>(.+?)<br>(.+?)</h\d>
kovidgoyal is online now   Reply With Quote
Old 12-28-2014, 11:35 AM   #7
phossler
Guru
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 897
Karma: 295106
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Thanks, but that RE doesn't seem to find anything. I made sure that there was no invisible trailing space in the Find expression ... this time

Quote:
calibre, version 2.14.0
ERROR: Not found: <p>No matches were found for <pre style="font-style:italic">(?s)&lt;h\d&gt;(.+?)&lt;br&gt;(.+?)& lt;/h\d&gt;</pre>
Sorry to be a pest, but I just finished manually TitleCasing a book with 40+ two line headings using the [Change Case] option, so I wanted to be ready the next time

Thanks
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	183
Size:	130.4 KB
ID:	133084  
phossler is offline   Reply With Quote
Old 12-28-2014, 12:22 PM   #8
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 25,186
Karma: 34462851
Join Date: Aug 2009
Location: The Central Coast of California
Device: K4NT(Fixed,New Bat.), Galaxy Tab A, Kobo Aura2
the BR did not include a space and self closing slash
Code:
(?s)<h\d>(.+?)<br\s*/>(.+?)</h\d>
Literals in the pattern must match exactly what you want to match

the \s* handles the unpretty (no space) condition of your original
theducks is offline   Reply With Quote
Old 12-28-2014, 12:44 PM   #9
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: 37,010
Karma: 16422171
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
(?s)<h\d>(.+?)<br\s*/?>(.+?)</h\d>
kovidgoyal is online now   Reply With Quote
Old 12-28-2014, 01:55 PM   #10
phossler
Guru
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 897
Karma: 295106
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Thanks to both of you for your help, but the Find string is still either finding too much or nothing, as well as returning entities which end up being ignored (i.e. the <br/> 's)

The User Manual example

Code:
<[Hh][1-6][^>]*>([^<>]+)</[hH][1-6]>
works fine if there are no < or > between the Hx tags and that's what I started with, i.e. trying to make it handle the case where there might be <br/> tags or not. I hadn't even gotten to the point of handling spaces

I'd appreciate any more ideas
Attached Thumbnails
Click image for larger version

Name:	Before.JPG
Views:	160
Size:	84.6 KB
ID:	133089   Click image for larger version

Name:	After.JPG
Views:	196
Size:	89.8 KB
ID:	133090  
phossler is offline   Reply With Quote
Old 12-28-2014, 10:55 PM   #11
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: 37,010
Karma: 16422171
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I tried the following expression and it works both for heading tags with <br> inside and without br inside.

Code:
<[Hh][1-6][^>]*>([^<>]*)(?:<[^<>]+>){0,1}([^<>]*)</[hH][1-6]>
kovidgoyal is online now   Reply With Quote
Old 12-29-2014, 09:16 AM   #12
phossler
Guru
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 897
Karma: 295106
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
Thanks very much

It will take me a while to understand it, but hopefully I'll learn some new reg ex techniques
phossler is offline   Reply With Quote
Old 12-29-2014, 01:34 PM   #13
BetterRed
null operator
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 16,226
Karma: 18817784
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by phossler View Post
Thanks very much

It will take me a while to understand it, but hopefully I'll learn some new reg ex techniques
Maybe this can help Regular Expression Analyzer

I've no idea if its any good, but I find it useful to try to unravel obscure RE.

BR

Last edited by BetterRed; 12-29-2014 at 01:37 PM.
BetterRed is offline   Reply With Quote
Old 12-29-2014, 02:54 PM   #14
phossler
Guru
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 897
Karma: 295106
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
@BR -- thanks. Very helpful.

I'm still looking for the RE that says "Do what I want" and not "What I Told You To Do"
phossler is offline   Reply With Quote
Old 12-30-2014, 05:07 PM   #15
phossler
Guru
phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.phossler ought to be getting tired of karma fortunes by now.
 
Posts: 897
Karma: 295106
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
I'm wondering if I have an issue with the actual TitleCasing RegEx-Function?

For this fragment ...


Code:
<body>

  <h1>TEST1 TEST1 TEST1 TEST1 TEST1 </h1>

  <p>NOW IS THE TIME and this should remain mixed case</p>

  <h1>TEST2 TEST2 TEST2 <br/><br/>TEST3 TEST3 </h1>

  <p>NOW IS THE TIME and this should remain mixed case</p>

  <h1>TEST4 <i>TEST4 TEST4 TEST4</i> TEST4 </h1>

</body>

... my Find expression

Code:
\<([Hh][1-6])\>.*?\</\1\>
... will find step through and highlight just the three H1 open/close pairs and what is between them (#2 in picture), but a Replace doesn't do anything except make the <h into a <H (#1 in picture)

It would seem to me that if the built in Title Case would ignore tags and what's in them, and just act on the 'Find' it should / would work for any embedded tags inside Hx pairs not just <br/>

Am I misunderstanding?
Attached Thumbnails
Click image for larger version

Name:	Capture.JPG
Views:	201
Size:	86.5 KB
ID:	133150  

Last edited by phossler; 12-30-2014 at 05:10 PM. Reason: Can't type
phossler is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
regex-function convert roman numerals weberr Editor 10 12-25-2014 10:31 PM
A regex function to number a mathematical ebook dmonasse Editor 3 12-23-2014 02:54 AM
Regex Function - Split unknown word Paulie_D Editor 19 12-07-2014 05:12 AM
Regex for Title Case or Sentence case? Turtle91 Sigil 3 01-19-2013 01:36 PM
Dutch title case function fvdham Library Management 8 10-11-2012 10:09 PM


All times are GMT -4. The time now is 02:58 AM.


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