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 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
Old 05-22-2022, 05:02 PM   #2
max-min
Member
max-min has a complete set of Star Wars action figures.max-min has a complete set of Star Wars action figures.max-min has a complete set of Star Wars action figures.
 
Posts: 13
Karma: 280
Join Date: Aug 2017
Device: touch lux
Quote:
Originally Posted by MerlinMama View Post
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.)
It seems it's related to your own thread https://www.mobileread.com/forums/sh...d.php?t=343893 , look at answer #5.
max-min is offline   Reply With Quote
Advert
Old 05-22-2022, 05:30 PM   #3
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
No, I tried that and it didn't work (I did go through that thread.) First, that was only for N/A, and I can't get it to work with the tags. With the tags, I can get #2 and #3 to work, but don't remember how I modified it for #1

Thank you though.
MerlinMama is offline   Reply With Quote
Old 05-23-2022, 04:02 PM   #4
max-min
Member
max-min has a complete set of Star Wars action figures.max-min has a complete set of Star Wars action figures.max-min has a complete set of Star Wars action figures.
 
Posts: 13
Karma: 280
Join Date: Aug 2017
Device: touch lux
Quote:
Originally Posted by MerlinMama View Post
With the tags, I can get #2 and #3 to work, but don't remember how I modified it for #1
OK, try this one, with the function you showed above :
Code:
Last Read:</b>\K(<em>N/A</em>| \d{1,2}/\d{2}/\d{4}|\s)
It will capture your 3 forms.
Explanation : You have to specify the text before the targeted text ("Last Read:</b>"), because you don't want to capture all spaces in the page . The \K reinitialize the pointer at this position (i.e. "forget the text found until this point")
max-min is offline   Reply With Quote
Old 05-25-2022, 10:12 AM   #5
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
Thank you, I'm not home for the rest of the week, but I will try when I get back
MerlinMama is offline   Reply With Quote
Advert
Old 05-29-2022, 02:23 AM   #6
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
Ok, that one worked! Thank you. I was sure I had tried that, but with all the variations I tried, I probably missed a few.

Again thank you so much!
MerlinMama 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
Random number in Regex Function? nqk Editor 2 05-23-2017 11:47 PM
Regex Function about «» and “” senhal Editor 8 04-06-2016 02:12 AM


All times are GMT -4. The time now is 07:44 PM.


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