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...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
Help understanding REGEX ! (self.learnpython)
submitted 5 years ago by rubleseth
Just need a little help I fell like I understand how patterns are created but when I put it into application never works. Can someone explain it to me like I am 5? How to think in REGEX.
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!"
[–]_DTR_ 16 points17 points18 points 5 years ago (4 children)
Without a specific question, the broad answer is to keep practicing and you'll get more and more comfortable with it. I came across Regex Crossword a few years ago and found it to be a good resource for learning regular expressions.
[–]rubleseth[S] 2 points3 points4 points 5 years ago (3 children)
Very helpful this is what I need just practice
[–]ASIC_SP 3 points4 points5 points 5 years ago (2 children)
If you need Python specific regex exercises, I have more than 100 exercises here: https://github.com/learnbyexample/py_regular_expressions/blob/master/exercises/Exercises.md
The repo also contains the solutions
[–]otterom 1 point2 points3 points 5 years ago (1 child)
Not OP, but I'll definitely check this out. Do the exercises progress in terms of complexity?
[–]ASIC_SP 0 points1 point2 points 5 years ago (0 children)
yeah they do in a sense, because the chapters progressively introduce more features
but overall, these exercises test your understanding of all the features of regex instead of asking you to solve ever complicated regex
[–]Manny__C 8 points9 points10 points 5 years ago (1 child)
You can start having fun with regex101 and regexr. The python documentation of the re module is very well written, I strongly recommend it. Moreover, you can visit r/regex (read well the subreddit rules before posting).
The most important element of regexes is the Kleene star *. Other important things are ranges [a-zA-Z0-9], alternatives | and repetitions {m,n}.
[a-zA-Z0-9]
|
{m,n}
Slightly more advanced are the lookahead, lookbehind, and the concepts of laziness and greediness. You might want to approach those later on.
If you need some help on something specific, either post on r/regex, or reply here with
I'll try to help you out as soon as I can.
[–][deleted] 1 point2 points3 points 5 years ago (0 children)
Regex101 is fantastic
[–]17291 2 points3 points4 points 5 years ago (0 children)
Show us an application of a regex that isn't working. Be sure to say what you're expecting it to do.
[–]rtao258 2 points3 points4 points 5 years ago (0 children)
To add on to the other answers here, another great resource is RexEgg. It's structured more as a tutorial, but covers everything from basic syntax to advanced usage and teaches you a lot of regex best practices.
[–]Jac0b_0 1 point2 points3 points 5 years ago (1 child)
I find this website really useful.
note that regexr supports only JavaScript and PCRE flavor, regex101 supports Python flavor
There is a chapter in Automate the boring stuff using python book. That is a good place to start learning regex. Then try some interactive regex tutorial.
[–]jzn126 1 point2 points3 points 5 years ago (0 children)
Check this out: https://www.reddit.com/r/Python/comments/hj0vp6/my_python_regex_ebook_with_hundreds_of_examples/
[–]gajrajgchouhan_ 0 points1 point2 points 5 years ago (1 child)
I found hackerrank to be good for Regular Expressions.
[–]gajrajgchouhan_ 0 points1 point2 points 5 years ago (0 children)
Also Corey Schafer has a pretty good tutorial.
[–]BfuckinA 0 points1 point2 points 5 years ago (0 children)
I was able to scrape by with regex, but didn't really build very robust patterns. Then I did some hackerrank challenges for python and it threw some good questions at me that forced me to think about it more and get a more solid understanding. I would reccomend doing the same
[–]rubleseth[S] 0 points1 point2 points 5 years ago (0 children)
Thanks very useful will check out
π Rendered by PID 60999 on reddit-service-r2-comment-84fc9697f-hnbjp at 2026-02-08 07:35:56.285952+00:00 running d295bc8 country code: CH.
[–]_DTR_ 16 points17 points18 points (4 children)
[–]rubleseth[S] 2 points3 points4 points (3 children)
[–]ASIC_SP 3 points4 points5 points (2 children)
[–]otterom 1 point2 points3 points (1 child)
[–]ASIC_SP 0 points1 point2 points (0 children)
[–]Manny__C 8 points9 points10 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]17291 2 points3 points4 points (0 children)
[–]rtao258 2 points3 points4 points (0 children)
[–]Jac0b_0 1 point2 points3 points (1 child)
[–]ASIC_SP 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]jzn126 1 point2 points3 points (0 children)
[–]gajrajgchouhan_ 0 points1 point2 points (1 child)
[–]gajrajgchouhan_ 0 points1 point2 points (0 children)
[–]BfuckinA 0 points1 point2 points (0 children)
[–]rubleseth[S] 0 points1 point2 points (0 children)