Skip to content

Instantly share code, notes, and snippets.

@marcotinacci
Last active July 17, 2017 15:25
Show Gist options
  • Save marcotinacci/6fdd4c713e16145cdfbd2a3ab41b0c85 to your computer and use it in GitHub Desktop.
Save marcotinacci/6fdd4c713e16145cdfbd2a3ab41b0c85 to your computer and use it in GitHub Desktop.
Python regex to remove any attribute from tags
import re
html = "<p class='myclass'>paragraph</p>"
html = re.sub("<([^> /]+)[ ]?[^>]*>","<\g<1>>", html)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment