View Single Post
Old 07-06-2020, 09:45 PM   #20
Ted Friesen
Nameless Being
 
Roman numerals

Quote:
Originally Posted by kovidgoyal View Post
@Papirus: Thankfully, calibre's editor is written in python so you dont have to create that unreadable gunk to do something like change case for roman numerals. Using the upcoming function mode, all you need is

Find: (?i)\b([ivclm]+)\b
Replace:
Code:
def replace(match, context):
    word = match.group()
    if word.lower() not in {set of common words}:
         word = word.upper()
    return word
I tried this regex-function. It returned an error that line 3 was not valid Python code. (Invalid syntax) What's wrong?
  Reply With Quote