'Regexextract multiple <a> links from HTML
I have an extract from a description off a webpage which contains multiple links to other pages the whole string is in a single cell. The string below is along the lines of
copy <a href="/sitelink1">Link 1</a>,<a href="/link2">Link 2</a>, <a href="/Link3">Link 3</a>
I would like to be able to use the regexextract function to pull the link URLs from the above string, it doesn't have to be that the all pull through into the same cell afterwards.
Managed to get the first link extracted using href="([^"]) however having no luck getting the 2nd and onwards links. Already tried using lookbehinds with (?<=href=)(.?)(?=>) but it seems Sheets doesn't support this in it's regex engine.
Open to using apps script to sort this if it makes things easier, just would love a solution as I'm at a wits end here.
Solution 1:[1]
try:
=ARRAYFORMULA(IFERROR(REGEXREPLACE(SPLIT(REGEXREPLACE(A2:A,
"(?s)^(.*?)href=""", ), "href=""", 0), """(.*)", )))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |