Created
June 3, 2020 23:05
-
-
Save oaguy1/de450170f0deff9785a585c126ebde38 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
raw_comment = "I hate u/oaguy1 and u/example123" | |
reddit_rx = re.compile(r"\b/?u/[\w-]{3,20}\b") | |
#returns "I hate USERNAME and USERNAME" | |
masked_comment = re.sub(reddit_rx, lambda x: "USERNAME", raw_comment) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment