Isaac Isaac - 1 year ago 107
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, "")

Answer Source

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, "")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download