Having used this script to great satisfaction for some time now, it seemed necessary to extend it for further use.
So I decided to do something about those strange German dates (day, month, year = "24. Dezember 1900"), which, apart from the noun for the month, also start with the smallest unit and end with the largest. This is not a good way to sort dates in a list. The ISO format "YYYY-MM-DD" is much better. (The above example would be "1900-12-24"). I get those German dates in long lists when I enter old German TV-shows in my Obsidian-Vault.
Here's a short example of what I get:
--------------------------------------------------------------
Code: Select all
27. Juli 1960
4. Oktober 1960
24. April 1961
6. April 1962
28. November 1962
and that's what I want/need:
My first idea, of course, was to transform them using cell formatting in LibreOffice Calc. I only get it to work half the time; it is very cumbersome.
--------------------------------------------------------------
Code: Select all
1960-07-27
1960-10-04
1961-04-24
1962-04-06
1962-11-28
1. Step:
--------------------------------------------------------------
I need to add a leading zero to the single digit (for days) at the beginning of the line
Code: Select all
4. Oktober 1960 -> 04. Oktober 1960
6. April 1962 -> 06. April 1962
Code: Select all
needleRegEx := '^(\d\.)' ; this will find a single digit a the beginning of the line
replacement := '0$1' ; this will add a leading zero
Now I remembered a script @mikeyww provided and I did nothing more than replace two values, i.e. needleRegEx and replacement (as shown above)
Code: Select all
!q:: {
Static needleRegEx := '^(\d\.)'
, replacement := '0$1'
A_Clipboard := '', Send('^a'), Send('^c')
If ClipWait(1) {
A_Clipboard := RegExReplace(A_Clipboard, needleRegEx, replacement)
Send '^v'
} Else MsgBox 'An error occurred while waiting for the clipboard.', 'Error', 48
return
}
First I tested it in SublimeText (~90 minutes of tweaking, changing, cursing), then in an act of desperation I switched to Brackets (where it worked exactly once (!)). Then I tried the rest of my editors, not understanding why a routine/script running "outside" of them should produce different results at all.
What's going on?
I am stuck
Thank you for your help
My editors: VSCode, SublimeText, Brackets, Notepad++
Only one step at the moment ...