I found a KM macro on the Internet, which copies the two-factor code to the clipboard.
https://tyler.io/a-better-way-to-copy-two-factor-codes-on-macos/
This also works very reliably for me under macOS Big Sur and macOS Monterey.
03)2FA <091D 220308T094346>.kmmacros (43,9 KB)
Click to show image
However, I have an advertiser who puts a dot directly after the number code - 765452. - because the number code is the end of a sentence.
Could someone please help me with which input you have to add to the following script to get this dot removed.
sqlite3 "$HOME/Library/Messages/chat.db" "select text from message order by date desc limit 1" | perl -lpe "s/.* (\d+) .*/\1/g"
tiffle
March 8, 2022, 9:54am
2
Not absolutely sure, but try this instead of the above
perl -lpe "s/.* (\d+).*/\1/g"
so the full script would be:
sqlite3 "$HOME/Library/Messages/chat.db" "select text from message order by date desc limit 1" | perl -lpe "s/.* (\d+).*/\1/g"
1 Like
Thank you @tiffle for the quick reply
Your supplement is the right solution. Now it also works if a dot is placed directly after the two-factor code.
1 Like
Sleepy
March 8, 2022, 5:58pm
4
My interpretation of the regex that you changed to is that it will now "work if any series of characters, not just a dot, appears after the 2FA code." That's because " .* " matches any series of characters. If you just want it to match only a dot, I think you have to replace ".*" with "\."
1 Like
tiffle
March 8, 2022, 6:25pm
5
The purpose of the regex is to extract the numeric code - whether followed by a dot or something else - which it does successfully @Sleepy
1 Like