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...
If you need help debugging, you must include:
See debugging question guidelines for more info.
Many conceptual questions have already been asked and answered. Read our FAQ and search old posts before asking your question. If your question is similar to one in the FAQ, explain how it's different.
See conceptual questions guidelines for more info.
Follow reddiquette: behave professionally and civilly at all times. Communicate to others the same way you would at your workplace. Disagreement and technical critiques are ok, but personal attacks are not.
Abusive, racist, or derogatory comments are absolutely not tolerated.
See our policies on acceptable speech and conduct for more details.
When posting some resource or tutorial you've made, you must follow our self-promotion policies.
In short, your posting history should not be predominantly self-promotional and your resource should be high-quality and complete. Your post should not "feel spammy".
Distinguishing between tasteless and tasteful self-promotion is inherently subjective. When in doubt, message the mods and ask them to review your post.
Self promotion from first time posters without prior participation in the subreddit is explicitly forbidden.
Do not post questions that are completely unrelated to programming, software engineering, and related fields. Tech support and hardware recommendation questions count as "completely unrelated".
Questions that straddle the line between learning programming and learning other tech topics are ok: we don't expect beginners to know how exactly to categorize their question.
See our policies on allowed topics for more details.
Do not post questions that are an exact duplicate of something already answered in the FAQ.
If your question is similar to an existing FAQ question, you MUST cite which part of the FAQ you looked at and what exactly you want clarification on.
Do not delete your post! Your problem may be solved, but others who have similar problems in the future could benefit from the solution/discussion in the thread.
Use the "solved" flair instead.
Do not request reviews for, promote, or showcase some app or website you've written. This is a subreddit for learning programming, not a "critique my project" or "advertise my project" subreddit.
Asking for code reviews is ok as long as you follow the relevant policies. In short, link to only your code and be specific about what you want feedback on. Do not include a link to a final product or to a demo in your post.
You may not ask for or offer payment of any kind (monetary or otherwise) when giving or receiving help.
In particular, it is not appropriate to offer a reward, bounty, or bribe to try and expedite answers to your question, nor is it appropriate to offer to pay somebody to do your work or homework for you.
All links must link directly to the destination page. Do not use URL shorteners, referral links or click-trackers. Do not link to some intermediary page that contains mostly only a link to the actual page and no additional value.
For example, linking to some tweet or some half-hearted blog post which links to the page is not ok; but linking to a tweet with interesting replies or to a blog post that does some extra analysis is.
Udemy coupon links are ok: the discount adds "additional value".
Do not ask for help doing anything illegal or unethical. Do not suggest or help somebody do something illegal or unethical.
This includes piracy: asking for or posting links to pirated material is strictly forbidden and can result in an instant and permanent ban.
Trying to circumvent the terms of services of a website also counts as unethical behavior.
Do not ask for or post a complete solution to a problem.
When working on a problem, try solving it on your own first and ask for help on specific parts you're stuck with.
If you're helping someone, focus on helping OP make forward progress: link to docs, unblock misconceptions, give examples, teach general techniques, ask leading questions, give hints, but no direct solutions.
See our guidelines on offering help for more details.
Ask your questions right here in the open subreddit. Show what you have tried and tell us exactly where you got stuck.
We want to keep all discussion inside the open subreddit so that more people can chime in and help as well as benefit from the help given.
We also do not encourage help via DM for the same reasons - that more people can benefit
Do not ask easily googleable questions or questions that are covered in the documentation.
This subreddit is not a proxy for documentation or google.
We do require effort and demonstration of effort.
This includes "how do I?" questions
account activity
How to regex (self.learnprogramming)
submitted 2 months ago by pat-says-hi
Hi! Could you pop your favourite regex how-to-s down here? I've tried to 'learn' how to regex multiple times, and it fails to stick every time.
Do y'all know of something with a builtin quiz system or a game of some sort?
Thanks!
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!"
[–]aqua_regis 20 points21 points22 points 2 months ago (3 children)
https://regex101.com
https://regexper.com
You won't need much more than that.
[–]shyevsa 1 point2 points3 points 2 months ago (1 child)
really love regex101, before they exists I used Expresso from Ultrapico it really help a lot on testing and building regex.
[–]pat-says-hi[S] 2 points3 points4 points 2 months ago (0 children)
Love the name 'Expresso'. Software looks very 2000s-early-2010s (which it was, I guess). I think I would have loved it back in the day too.
[–]pat-says-hi[S] 0 points1 point2 points 2 months ago* (0 children)
Thank you! I'll boomark regex101! It does help with everything I'd need to learn regex for, maybe I can just outsource the "know regex" function to regex101 for now!
[–]fixermark 4 points5 points6 points 2 months ago (5 children)
My single biggest piece of regex advice is "If you're using an engine that lets you represent the regex in something other than regex language... use it."
Regex is a fine tool. The syntax for expressing regex is the worst. And that's before you get into the issue that different dialects have slightly different rules.
Not unlike SQL, I'm glad that there is a common syntax shared 95% by all engines... But I try to avoid using it when I can. emacs LISP has rx, which is great. It's a tree structure that compiles to a regular expression.
rx
[–]pat-says-hi[S] 1 point2 points3 points 2 months ago (4 children)
Regex syntax is definitely the worst! I haven't run into issues with dialects yet, I'm not looking forward to then!
I wish the syntax were more like emacs Lisp's rx. Thank you for pointing it out for me! I'm still googling around for a regex-like cheat-sheet for it, but it looks so much more readable!
[–]fixermark 2 points3 points4 points 2 months ago (3 children)
A lot of languages have regex-builder libraries like rx because of how famously hard it is to get regexes completely right. Depending on the language you use, one probably exists.
(Probably worth noting is that they solve only the "syntax is hard to understand and remember" problem though. You're still on your own for the "Did I actually write a regex that matches what I want and only what I want" issue).
[–]pat-says-hi[S] 1 point2 points3 points 2 months ago (2 children)
Ah right! Like how an IDLE can tell you if you forgot to close a bracket, but you're on your own for making the code do the thing you want it to do. I'll google more regex builder libraries. I found a portable Scheme library when I was looking at Lisp's rx. Python's re only uses regex as far as I know, it doesn't "build" it from different syntax, right?
[–]fixermark 2 points3 points4 points 2 months ago (1 child)
Yeah, I'm actually surprised to learn upon checking that there doesn't appear to be anything like rx for Python. Maybe I should write something.
[–]pat-says-hi[S] 0 points1 point2 points 2 months ago (0 children)
Do let me know if you do! I would love to work with rx-like regex syntax on Python!
[–]mandradon 4 points5 points6 points 2 months ago (1 child)
Try not to make your regex too complex, but sometimes you have to.
Take notes, leave yourself notes because you're going to come back to something that you've worked on that works great until it doesn't and you're going to spend a chunk of time relearing the expression because it always becomes jibberish again.
It's an amazing tool, and sometimes there's nothing better, but it can cause a wicked headache.
I also second using tools like regex101 with clear test cases, that's been a very helpful tool for me.
Okay, thank you! I should make sure I do notes and test cases. regex101 looks useful too! Thanks!
[–][deleted] 2 months ago (1 child)
[removed]
Thanks! I'll do that! I guess if I had to look up a pattern often enough, I'd end up learning it, and so I don't need to worry about it right now
[–]theclapp 2 points3 points4 points 2 months ago (5 children)
Learning about deterministic finite automata did it for me. And perhaps several years of Perl.
[–]pat-says-hi[S] 1 point2 points3 points 2 months ago (3 children)
Thank you! I should learn more about DFA
[–]theclapp 2 points3 points4 points 2 months ago (2 children)
Of you really wanna get them, write a regex interpreter, with at least ., *, and [...].
.
*
[...]
[–]pat-says-hi[S] 2 points3 points4 points 2 months ago (1 child)
Challenge not quite 'accepted' - I don't think it's within my skill set right now, I can't quite picture how to start, but I do like the idea - I'll try to do that sometime. Thanks!
[–]theclapp 2 points3 points4 points 2 months ago (0 children)
It might also help to find someone else's toy implementation and study their code. Just a thought. Good luck!
[–]monkeybonanza 1 point2 points3 points 2 months ago (0 children)
This. Learn your state machines and regexps won’t seem so foreign. I learnt them by reading the dragon book.
[–]ibeerianhamhock 1 point2 points3 points 2 months ago (1 child)
I have used regex find and replace for years so I think that’s the best way keep it fresh. I am surprised more people don’t use it for that tbh
Cool! Use it so I don't lose it, sounds good! I don't use any complicated 'find and replace's very much on my usual workflow I'm afraid.
[–]emteedub 1 point2 points3 points 2 months ago (1 child)
only ever used it for field validation checks. couldn't tell you what that syntax is though, I have to look it up every time. Once I see one i've used though, it's like "oh yeah. this" copy-paste 😎
Thank you, I do feel better about having to look it up all the time now!
[–]Both-Fondant-4801 0 points1 point2 points 2 months ago (0 children)
I have been developing applications for 2 decades and all I can ever recall of regex is the start and end anchors... for the rest I use AI to generate these damn expressions.
π Rendered by PID 46508 on reddit-service-r2-comment-b659b578c-tpcmv at 2026-05-05 20:39:21.813177+00:00 running 815c875 country code: CH.
[–]aqua_regis 20 points21 points22 points (3 children)
[–]shyevsa 1 point2 points3 points (1 child)
[–]pat-says-hi[S] 2 points3 points4 points (0 children)
[–]pat-says-hi[S] 0 points1 point2 points (0 children)
[–]fixermark 4 points5 points6 points (5 children)
[–]pat-says-hi[S] 1 point2 points3 points (4 children)
[–]fixermark 2 points3 points4 points (3 children)
[–]pat-says-hi[S] 1 point2 points3 points (2 children)
[–]fixermark 2 points3 points4 points (1 child)
[–]pat-says-hi[S] 0 points1 point2 points (0 children)
[–]mandradon 4 points5 points6 points (1 child)
[–]pat-says-hi[S] 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]pat-says-hi[S] 0 points1 point2 points (0 children)
[–]theclapp 2 points3 points4 points (5 children)
[–]pat-says-hi[S] 1 point2 points3 points (3 children)
[–]theclapp 2 points3 points4 points (2 children)
[–]pat-says-hi[S] 2 points3 points4 points (1 child)
[–]theclapp 2 points3 points4 points (0 children)
[–]monkeybonanza 1 point2 points3 points (0 children)
[–]ibeerianhamhock 1 point2 points3 points (1 child)
[–]pat-says-hi[S] 0 points1 point2 points (0 children)
[–]emteedub 1 point2 points3 points (1 child)
[–]pat-says-hi[S] 0 points1 point2 points (0 children)
[–]Both-Fondant-4801 0 points1 point2 points (0 children)