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:
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:
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:
Thanks so much for this useful tip! FYI, I’ve encountered an odd wrinkle in this approach that pops up only when the column for the entered page link is populated programmatically (as opposed to manually).
I have a button that duplicates a page and stores it in one column and then a second column with the formula you provided to generate a URL suffix. Whenever the button action executes, though, the output in the second column ends up having the document URL path included, as well. That is to say, it comes out looking something like this:
/d/_d3q6RXwsMKW/Another-Test_su2dQ
To get around this, I’ve simply included some additional formula arguments:
ToText([Entered Link]).split("/").last()
That seems to do the trick for me. That said, I’d be grateful if you could provide any insight into why programmatically generated links are handled differently, in the first place.
This does not seem to work for me. I copied the formula and then pasted it into my table and changed the OBJECT referenced. The object I’m using is a Text field in a table that I paste a URL into. I get only in my table field where this formula exists. I am copying and pasting a URL for orders say from Amazon and when it pasts it has the URL and then text like “Order Details”. I need to get the url. This sounds like it is what I need, but it does not seem to work. So is this ONLY working with links to CODA objects?
@BenLee So I see there’s an option for getting the URL from the hyperlink. But is there a way to get the Display text?
Usecase: I have a table with one column with links to other pages in the coda doc. The links are displayed with the name of the page as the display text rather than just a URL.
In another column, I want to extract just the plaintext of the display name.