I struggling to find the correct LUA code to detect if two dates appear after each other.
I have something similar which detects two keywords, but it's not working on my dates.
Here's the LUA code I have so far:
(%a+) %- %1$
Cheers,
Your main trouble here is that you want to match a date like 2017-03-19
with %a+
pattern. %a
matches a letter, %a+
matches 1 or more letters.
You need to replace this pattern with a more precise one, like %d+%-%d+%-%d+
or %d%d%d%d%-%d%d%-%d%d
:
'(%d+%-%d+%-%d+) %- %1'
where %d
matches a digit.
Now, if you want to match a whole string like this, you need to enclose the pattern with ^
and $
anchors.
'^(%d+%-%d+%-%d+) %- %1$'
If you want to add word boundaries,
'%f[%d](%d+%-%d+%-%d+) %- %1%f[%D]'