08-02-2023, 11:05 PM | #1 |
Evangelist
Posts: 487
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Libra Colour
|
Help with S&R RegEx Function
Something strange just happened. I was correcting some fanfics I just finished reading. I have a Saved Search that I use to modify my Last Read date on the cover page.
I did one of the fics, no problem. I closed the first fic, opened the second one, and it no longer works correctly. I have no clue. On my cover page, the line is: Spoiler:
The find portion of the saved search is: Spoiler:
I use a Regex-Function for the replace portion of the saved search: Spoiler:
Now when I hit find on the saved search it only highlights the following section: Spoiler:
I want to be clear that I did not do any editing AT ALL in the saved search (even for another saved search). I hope someone can clear this up for me. |
08-03-2023, 03:16 PM | #2 |
Evangelist
Posts: 487
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Libra Colour
|
After fiddling around, I managed to get something workable. I would still like to know, if possible, why what I had stopped working so suddenly. I had set up the regex-function over a year ago in a basic form, but about 6 or so months ago, I changed the format on my cover page and added the '</dt><dd>' part only.
I had to remove '\K' from the find, and I changed the regex-function part to: Spoiler:
**I added the underline here to show what I added, it is not in the actual regex-function** If there is a better way to accomplish this, any suggestions are welcome! |
Advert | |
|
08-16-2023, 12:16 PM | #3 |
Zealot
Posts: 136
Karma: 1000102
Join Date: Jul 2021
Device: N/A
|
|
08-16-2023, 12:28 PM | #4 |
Evangelist
Posts: 487
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Libra Colour
|
I can't imagine that searching up or down would change anything? Of course my knowledge of all this is EXTREMELY limited.
At any rate, I've fiddled with it and got it to work, so it's all good now. I might make a test entry just to see when I have time. |
08-16-2023, 12:53 PM | #5 |
Zealot
Posts: 136
Karma: 1000102
Join Date: Jul 2021
Device: N/A
|
It's because of the \K. When you're searching upward, it looks for the last part of the regex (after the \K) and discard it, then it searches the first part
If you want that the regex works both directions, substitute the /K by a lookbehing condition : Code:
(?<=Last Read:</b></dt><dd>)((<em>)?N/A(</em>)?| \d{1,2}/\d{2}/\d{4}| \d{1,2}-\d{2}-\d{4}|\s) |
Advert | |
|
08-16-2023, 12:57 PM | #6 |
Evangelist
Posts: 487
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Libra Colour
|
Ok, good to know. I always search down, but I do remember at one point noticing it was up, so that is probably it. I'll still test it, because actually seeing it will help drill it into my memory
Thanks |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help with S&R RegEx Function | MerlinMama | Editor | 5 | 05-29-2022 02:23 AM |
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 Function about «» and “” | senhal | Editor | 8 | 04-06-2016 02:12 AM |