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

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 12-31-2012, 11:36 AM   #1
Turtle91
Guru
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
Posts: 669
Karma: 3807234
Join Date: Dec 2012
Location: Shannon, Ireland today
Device: iPhone 5/iPad 1&2/Surface Pro/Kindle PW
Regex for Title Case or Sentence case?

Hi,

I've found and used (successfully) a regex for UPPERCASE/LOWERCASE using the \U \u \L \l \E markers.

Does anyone know of a way to use regex to transform a selection to sentence case or title case?

I'm trying to make transformation from ALL CAPS at the beginning of sentences (first paragraph) or in headers a little more automated. Sigil makes it very easy to manually change a highlighted range of text, but I was hoping for something I can put in the "replace" portion of the Find/Replace.

Ideally there would be something like \S or \T. e.g.:

Find: (<p class="first">)([[:upper:] \?!'-\.]{2,})([a-z]|</p>)
(selects all uppercase letters until it finds a lowercase letter OR the end of paragraph)

Replace: \1\T\2\E\3 (for Title Case)
Replace: \1\S\2\E\3 (for Sentence case)



I was trying this for sentence case - and it "seems" to work - but it changes the whole document; which is good if you are fixing grammar...

Find: ([\.|?|!])(\s*)(["|“|‘]?)([a-z])
Replace: \1 \3\u\4

Cheers!

Last edited by Turtle91; 12-31-2012 at 11:53 AM.
Turtle91 is offline   Reply With Quote
Old 01-18-2013, 04:50 PM   #2
Steadyhands
Enthusiast
Steadyhands began at the beginning.
 
Steadyhands's Avatar
 
Posts: 28
Karma: 10
Join Date: Dec 2011
Location: Brisbane, Oz
Device: iPad2
Any news on something like this working?
Steadyhands is offline   Reply With Quote
Old 01-18-2013, 08:23 PM   #3
theducks
Grand Sorcerer
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: 14,276
Karma: 5495472
Join Date: Aug 2009
Location: The (original) Silicon Valley, USA
Device: Galaxy Tab 2, Astak Pocket Pro, K4NT
Most Mixed case switches I have used require that you start with lower case.
so you could do this in 2 passes ( put a unique marker pair as part of the first replace)

AND THE WORLD WAS FLAT
+and the world was flat+

Now search for the pair \+(.+?)\+

and perform your magic
theducks is offline   Reply With Quote
Old 01-19-2013, 01:36 PM   #4
Steadyhands
Enthusiast
Steadyhands began at the beginning.
 
Steadyhands's Avatar
 
Posts: 28
Karma: 10
Join Date: Dec 2011
Location: Brisbane, Oz
Device: iPad2
Quote:
Originally Posted by theducks View Post
Most Mixed case switches I have used require that you start with lower case.
so you could do this in 2 passes ( put a unique marker pair as part of the first replace)

AND THE WORLD WAS FLAT
+and the world was flat+

Now search for the pair \+(.+?)\+

and perform your magic
Thanks.
Steadyhands 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
Title Case and Handling Name Suffixes rcandi Calibre 2 10-09-2011 10:30 AM
upper case to sentence case conversion cybmole Sigil 8 01-20-2011 06:03 AM
Conversion to title case Seanette Calibre 23 10-27-2010 01:01 PM
Any chance of 'Title Case' being improved? kiwidude Calibre 6 10-11-2010 12:40 PM
Title Case Dopedangel Calibre 6 10-16-2009 08:01 AM


All times are GMT -4. The time now is 01:48 PM.


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