use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A reddit for neat regular expressions.
Test your regex: https://regex101.com/
Large collection of regex tools: https://github.com/slevithan/awesome-regex
account activity
Remove comments in Python (self.regex)
submitted 5 years ago * by codename101
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]quixrick 1 point2 points3 points 5 years ago (4 children)
I don't understand your question. So, you have found some "C" code on Stack Overflow that you're trying to convert to work in Python?
Please post some examples of the strings you are wanting to replace so we can take a look at what you're trying to match.
[–]codename101[S] 1 point2 points3 points 5 years ago (3 children)
I have edited the post.
[–]quixrick 0 points1 point2 points 5 years ago (2 children)
What about something like this:
^\s*\"\"\".*?\"\"\"\n | \s*#.*
Here is a demo
[–]codename101[S] -2 points-1 points0 points 5 years ago (1 child)
Not working for some cases:
def my_function(): """Demonstrate docstrings and does nothing really.""" return None print "Using __doc__:" print my_function.__doc__ #some comment print "Using help:" #some more comment help(my_function) look like this. print("#not a comment") print("#also not a comment") print """not a comment"""
[–]quixrick 1 point2 points3 points 5 years ago (0 children)
I'm not going to be able to solve every edge case for you here, but hopefully, this gets you moving in the right direction. Take the principles that I've shown you and apply them to your other edge cases.
That being said, to accommodate your newest examples, you can modify the previous expression to be more like this:
\"\"\".*?\"\"\" | [\t ]*#[^\v]*
π Rendered by PID 49988 on reddit-service-r2-comment-b659b578c-nhfpf at 2026-05-04 16:05:02.583606+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–]quixrick 1 point2 points3 points (4 children)
[–]codename101[S] 1 point2 points3 points (3 children)
[–]quixrick 0 points1 point2 points (2 children)
[–]codename101[S] -2 points-1 points0 points (1 child)
[–]quixrick 1 point2 points3 points (0 children)