Skip to content

Instantly share code, notes, and snippets.

@impure
Last active October 28, 2021 21:25
Show Gist options
  • Save impure/b47e29dc4fddf38a68d3dc3fc651691e to your computer and use it in GitHub Desktop.
Save impure/b47e29dc4fddf38a68d3dc3fc651691e to your computer and use it in GitHub Desktop.
import clipboard
import re
text = clipboard.paste()
start = text.find("Posted by")
end = text.rfind("Reply\nGive Award\nShare\nReport\nSave\nFollow\nAbout Community")
if start == -1 or end == -1:
print(text)
exit()
text = text[start:end]
text = text.replace("Reply\nGive Award\nShare\nReport\nSave\nFollow\nAbout Community", "")
text = text.replace("Reply\nGive Award\nShare\nReport\nSave\nFollow", "")
text = text.replace("Comments\n\nAward\n\nShare\n\nSave\n\nHide\n\nReport", "")
text = text.replace("Comments\n\nAward\n\nShare\n\nSave\n\nHide", "")
text = re.sub(r'\n+', r'\n', text)
print(text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment