Skip to content

Instantly share code, notes, and snippets.

@Steffo99
Created January 18, 2018 08:08
Show Gist options
  • Select an option

  • Save Steffo99/bc9c44342ecb9763338d03f9ae00e21f to your computer and use it in GitHub Desktop.

Select an option

Save Steffo99/bc9c44342ecb9763338d03f9ae00e21f to your computer and use it in GitHub Desktop.
#!/usr/bin/python3.6
import cgi
import re
print("Content-Type: text/html")
print()
print("<style>span::before { color: red; content: '('; } span::after { color: red; content: ')'; }</style>")
form = cgi.FieldStorage()
if form["regex"].value == "":
print("<h1>No regex specified.</h1>")
print(re.sub(r"(" + form["regex"].value + ")", r"<span>\1</span>", form["text"].value))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment