dave-kennedy / clean-html

HTML cleaner and beautifier for Node
The Unlicense
47 stars 10 forks source link

How to remove all HTML 'attributes' or 'tags' EXCEPT a certain one (or two) #15

Closed Nantris closed 6 years ago

Nantris commented 6 years ago

I'd like to remove every attribute that isn't src or href but I'm having a hard time figuring out regex that I can pass to this option to achieve that. Is this currently possible?

Thanks again for the great package and for your help in the past.

dave-kennedy commented 6 years ago

Try /^((?!src|href).)*$/.

I don't quite understand it, but the explanation is here.

Nantris commented 6 years ago

Thanks very much, I'll give this a shot!