Thanks for clarifying, that was easier to understand.
I presume the displayed text for a given link could be of any length and word count ? The example you gave using "GET" seems very precise, but I'm going to proceed as if you intended a more generalised example.
var anchorText = 'Copy link address';
This performs a case-insensitive, fuzzy search, which will match any anchor text that contains the given
To perform an exact match, this code will achieve that:
var anchorText = 'Copy link address (Chrome or Safari) (Newbie alert)';
To demonstrate how this is implemented within a KM macro, I've created this one:
Find Links Using Anchor Text.kmmacros
A Typed String-triggered macro, triggered by entering text of the form
A[%anchorText%] in any text box, where:
A: is a literal uppercase or lowercase "A", signifying that the anchor text to be supplied is to be matched exactly (uppercase) or fuzzily (lowercase).
%anchorText%: is the text supplied against which hyperlinks are to be matched by their text content, to within the allowances provided for by
The trigger text is removed and replaced with the matching URL(s), which are also stored on the clipboard.
A[Find Links Using Anchor Text.kmmacros]➔
A[Find Links Using]➔
(empty string) (i.e. no matches)
https://forum.keyboardmaestro.com/u/Luoto, https://forum.keyboardmaestro.com/u/Luoto, https://forum.keyboardmaestro.com/t/copy-link-address-chrome-or-safari-newbie-alert/10177/3