Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 12-04-2021, 09:24 PM   #1
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,611
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Regex to convert to Uppercase

Hi,

I am using the Calibre book editor and I am trying to convert the first letter of the chapter headings from lowercase to uppercase.

My search regex is...
PHP Code:
<class="calibre_3" id=".*?"><span class="calibre2"><span class="bold">(\w)(.*?)</span></span></p
My replace regex is...
PHP Code:
<h2>\U\1\E\2</h2
But I keep getting the following error message...
calibre, version 5.32.0
Spoiler:
ERROR: Unhandled exception: <b>error</b>:incomplete escape \U at position 7

calibre 5.32 embedded-python: True is64bit: False
Windows-10-10.0.19041 Windows ('32bit', 'WindowsPE')
32bit process running on 64bit windows
('Windows', '10', '10.0.19041')
Python 3.8.5
Windows: ('10', '10.0.19041', '', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (1, 45, 0) && Package KFX (from KFX Input) (1, 45, 0) && EpubCheck (0, 2, 3) && KFX metadata reader (from KFX Input) (1, 45, 0) && KFX Input (1, 45, 0) && Set KFX metadata (from KFX Output) (1, 57, 0) && KFX Output (1, 57, 0) && Kindle Collections (1, 7, 29) && && Kobo Utilities (2, 14, 1) && Manage Series (1, 2, 11) && ScrambleEbook (0, 4, 5)
Traceback (most recent call last):
File "calibre\gui2\tweak_book\boss.py", line 1114, in search
File "calibre\gui2\tweak_book\search.py", line 1561, in run_search
File "calibre\gui2\tweak_book\search.py", line 1468, in do_replace
File "calibre\gui2\tweak_book\editor\widget.py", line 329, in replace
File "calibre\gui2\tweak_book\editor\text.py", line 598, in replace
File "regex\regex.py", line 684, in _compile_replacement_helper
File "regex\_regex_core.py", line 1690, in _compile_replacement
File "regex\_regex_core.py", line 1757, in parse_repl_hex_escape



I can't see where I am going wrong. Does anybody know?

Thanks
Karellen is offline   Reply With Quote
Old 12-04-2021, 11:47 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: 45,347
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There is no \U operator in calibre's regex engine. You should use function mode: https://manual.calibre-ebook.com/function_mode.html
kovidgoyal is offline   Reply With Quote
Advert
Old 12-05-2021, 12:37 AM   #3
Karellen
Wizard
Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.Karellen ought to be getting tired of karma fortunes by now.
 
Karellen's Avatar
 
Posts: 1,611
Karma: 9500498
Join Date: Sep 2021
Location: Australia
Device: Kobo Libra 2
Quote:
Originally Posted by kovidgoyal View Post
There is no \U operator in calibre's regex engine. You should use function mode: https://manual.calibre-ebook.com/function_mode.html
Oh, right. Thanks @kovidgoyal

That is what I ended up doing. I used the preset regex-function for Title case.
Karellen is offline   Reply With Quote
Old 12-05-2021, 04:43 AM   #4
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,727
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by Karellen View Post
My replace regex is...
PHP Code:
<h2>\U\1\E\2</h2
FYI: Sigil uses a different regex engine that supports this syntax. If you need to capitalize text other than titles, you could add Sigil to the open with menu and use it for these cases.
Doitsu is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
regex-function convert roman numerals weberr Editor 11 09-22-2021 05:15 PM
Help with uppercase ajean4 Library Management 0 04-19-2021 11:14 AM
Regex to find author names all in uppercase? Vortex Library Management 3 08-03-2016 06:50 PM
Help with Regex - find groups of words in uppercase Hoods7070 Sigil 3 06-11-2013 08:41 AM
Touch Uppercase!! snirp Kobo Reader 4 02-12-2012 10:08 PM


All times are GMT -4. The time now is 09:06 AM.


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