Isaac Isaac - 10 months ago 62
HTML Question

Regex for Removing HTML Links

I am trying to create a regex to remove all links from a HTML table so that the links will not display when the table is exported to excel. I am using the line of JavaScript below which removes everything except the link text. Any suggestions on how to remove the link text as well? Thanks.

tableHTML = tableHTML.replace(/<a[^>]*>|<\/a>/g, "")


I'm not sure what are you trying to do, But if you want to remove all links, this pattern would help you:


Online Demo

Full Code:

tableHTML = tableHTML.replace(/<a.*?a>/gm, "")