4 ms·
Hello! I wrote a GUI app written in `tkinter` to help you practice Python regular expressions. Total 75 questions on `re.search`, `re.sub`, `re.split` and `re.
by asicsp 5y ago
Hello!
I wrote a GUI app written in `tkinter` to help you practice Python regular expressions. Total 75 questions on `re.search`, `re.sub`, `re.split` and `re.findall` that'll test your understanding of anchors, alternation, grouping, escaping metacharacters, dot metacharacter, quantifiers, character class, grouping, lookarounds, flags, etc.
These exercise questions have been adapted from my "Python re(gex)?" ebook (free to read online [0]). See Exercises.md [1] for all the exercise questions from this book.
I'd appreciate your feedback :)
[0] https://learnbyexample.github.io/py_regular_expressions/ https://learnbyexample.github.io/py_regular_expressions/
[1] https://github.com/learnbyexample/py_regular_expressions/blob/master/exercises/Exercises.md https://github.com/learnbyexample/py_regular_expressions/blo...
- oraoraoraoraora 5y agoWas looking for a December project... thank you for this.
- mci 5y agoI like it! Here is a gotcha my students stumble on. I have not noticed it while skimming your book: ^ and $ do not have special priorities. To match alternatives, write ^(abc|def)$, not ^abc|def$
- asicsp 5y agoYeah, that's a good case to be aware of. I do mention it in the book while discussing anchors (indicating alternatives have their own independent anchors) [0] and grouping [1]. I also discuss how `re.fullmatch` is useful, especially when constructing an alternation pattern from a list of terms. Easier to use fullmatch instead of manually adding a group and string anchors. [0] https://learnbyexample.github.io/py_regular_expressions/alternation-and-grouping.html#alternation https://learnbyexample.github.io/py_regular_expressions/alte... [1] https://learnbyexample.github.io/py_regular_expressions/alternation-and-grouping.html#grouping https://learnbyexample.github.io/py_regular_expressions/alte...
- staticautomatic 5y agoWithout the group, does this match abc at the start or def at the end?
- schoen 5y agoYes, exactly.
- deleted 5y ago[deleted]