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 07-22-2021, 04:50 PM   #1
staceytoob
Junior Member
staceytoob began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Mar 2013
Device: nexus 7
Help! I broke my Capitalize Regex function.

Hello! Whilst trying to refine my regex for "find the first four all-caps words in a sentence, then change it to Capitalized text" I was using the regex-function Capitalize text (ignore tags). I stupidly tried to edit the code, not knowing what the heck i was doing, and now it won't perform the function (i.e. finds fo instances) or deletes those four words.

Can someone c/p the code that goes in the create/edit dialogue? I would be ever-so-grateful.
Attached Thumbnails
Click image for larger version

Name:	regex-function-capitalize-notags.png
Views:	209
Size:	141.5 KB
ID:	188306  
staceytoob is offline   Reply With Quote
Old 07-23-2021, 12:31 AM   #2
phossler
Wizard
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: 1,087
Karma: 447222
Join Date: Jan 2009
Location: Valley Forge, PA, USA
Device: Kindle Paperwhite
This is what I got.


Code:
from calibre.utils.icu import capitalize
from calibre.ebooks.oeb.polish.utils import apply_func_to_html_text

def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    '''Capitalize matched text, ignoring the text inside tag definitions.'''
    return apply_func_to_html_text(match, capitalize)
phossler is offline   Reply With Quote
Advert
Old 07-28-2021, 09:48 PM   #3
staceytoob
Junior Member
staceytoob began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Mar 2013
Device: nexus 7
Thank you SO VERY much. I appreciate your answer!
staceytoob is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help creating possible Regex-Function MerlinMama Editor 14 03-03-2020 05:53 AM
Predefined regex for Regex-function sherman Editor 3 01-19-2020 05:32 AM
regex function replacement The_book Sigil 5 12-09-2019 09:45 AM
regex capitalize first letter larysa Editor 8 10-23-2017 12:04 PM
Regex Function about «» and “” senhal Editor 8 04-06-2016 02:12 AM


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


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