Extracting URL's from Hyperlinks

While importing some text to a Coda doc, I stumbled upon the fact that it is quite difficult to get at the URL of a hyperlink if it has display text that is not the URL itself. There is no ‘ExtractURL()’ formula or equivalent for this purpose.

After some playing around, I have come up with a workaround that relies on the hidden _Merge() formula to get at the link object’s data. You can see how to do so here:

Hope it’s helpful!


Dear @Noah-ext,

Welcome to the community :handshake: your share is of great value :diamond_shape_with_a_dot_inside:


Welcome @Noah-ext!

That’s a really cool solution. I never would have found that on my own.

Thanks a ton for posting!


I just came across a similar need (extract URL from a reference in the text) and solved it with a different formula. It’s not relying on http because the links I’m interested in are local Coda links:

RegexExtract(_Merge(thisRow.[Entered link]) + "", '(?<="url":").*?(?=")')

Use case: quickly insert a reference to a table/view or a section, and get their URL to use with Hyperlink() / OpenWindow() elsewhere in the doc. This regex is not global and only returns the first "url" match in the rich text data object.

Also FYI a trick to turn @-references into lookup references:

P.S. Oddly enough, simply ToText() works just as fine on @-refs:

But then it doesn’t work in the original case (hyperlink with text override). So my Regex solution is still the universal one.

1 Like