View Single Post
Old 05-21-2022, 03:26 PM   #1
MerlinMama
Evangelist
MerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beauty
 
MerlinMama's Avatar
 
Posts: 498
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Sage
Help with S&R RegEx Function

I recently lost all my saved searches (my own fault) and while I have recovered them from a backup, there were a few tweaks I did that I can't for the life of me remember how I did them. There is one, in particular, I hope to get help with.

I currently have three different "Last Read" versions on my ebooks/fics:
  1. <b>Last Read:</b> <br/><br/>
  2. <b>Last Read:</b><em>N/A</em><br/><br/>
  3. <b>Last Read:</b> 02/02/2022<br/><br/>

Here is the "Find" I have recovered from my backup, which I can get to work for the 2nd & 3rd versions above:

Code:
(<em>N/A</em>| \d{1,2}/\d{2}/\d{4})
but I had at some point modified things so that I could also search for just a space, but I don't know what I did to accomplish that. My current replace (what I had before and now, since this wasn't affected by the loss of my saved searches) is:

Code:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    from datetime import datetime
    return datetime.now().strftime(" %m/%d/%Y")
I have no idea what I did, but for the last 2 months or so, whenever I would add a book, my title page would have the first option of Last Read above, and when I was done, I would just run my saved search and it would insert the correct date. I just don't remember how I did it.

Can anyone help?

(I *might* have set up a separate S&R for that one, but I'm 98% positive I didn't.)
MerlinMama is offline   Reply With Quote