HTML/XML manipulation by regular expressions in JavaScript (RegExp)
/** | |
* JS remove HTML/XML attribure regexp. | |
*/ | |
function removeAttribute(html, tagName, attrName) { | |
return html.replace(new RegExp(`(<${tagName}.*?)\\s+${attrName}=(["']).*?\\2(.*?>)`, 'gmi'), '$1$3'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment