Skip to content

Instantly share code, notes, and snippets.

@zimeon
Created April 3, 2020 20:35
Show Gist options
  • Save zimeon/670d6f55e53acd986b89accc69a42fe0 to your computer and use it in GitHub Desktop.
Save zimeon/670d6f55e53acd986b89accc69a42fe0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import re
import sys
e = 0
w = 0
def exxx(m):
global e
e += 1
return '<span id="E%03d">%s</span>' % (e, m.group(1))
def wxxx(m):
global w
w += 1
return '<span id="W%03d">%s</span>' % (w, m.group(1))
with open('index.html', 'r') as fh:
for line in fh:
line = re.sub(r'''(MUST NOT|MUST)''', exxx, line)
line = re.sub(r'''(SHOULD NOT|SHOULD)''', wxxx, line)
sys.stdout.write(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment