You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<content type="html"><p>Having an interactive program that automatically loads questions and checks the solution is wonderful to have while learning a topic. This <a href="https://github.com/learnbyexample/TUI-apps/blob/main/PyRegexExercises">TUI app</a> has beginner to advanced level exercises for Python regular expressions. There are more than 100 exercises covering both the builtin <code>re</code> and third-party <code>regex</code> module.</p>
<h2 id="installation">Installation<a class="zola-anchor" href="#installation" aria-label="Anchor link for: installation">🔗</a></h2>
20
+
<p>This app is available on PyPI as <a href="https://pypi.org/project/regexexercises/">regexexercises</a>. Example installation instructions are shown below, adjust them based on your preferences and OS.</p>
<p>To run the app without having to enter the virtual environment again, add this alias to <code>.bashrc</code> (or equivalent):</p>
31
+
<pre data-lang="bash" style="background-color:#f5f5f5;color:#1f1f1f;" class="language-bash "><code class="language-bash" data-lang="bash"><span style="color:#7f8989;"># you&#39;ll have to change the path
<p>As an alternative, you can install <code>textual</code> (see <a href="https://textual.textualize.io/getting_started/">Textual documentation</a> for more details), clone my <a href="https://github.com/learnbyexample/TUI-apps">TUI-apps</a> repository and run the <code>pyregex_exercises.py</code> file.</p>
35
+
<p>Adjust the terminal dimensions for the widgets to appear properly, for example 84x25 (characters x lines).</p>
36
+
<br>
37
+
<h2 id="brief-guide">Brief Guide<a class="zola-anchor" href="#brief-guide" aria-label="Anchor link for: brief-guide">🔗</a></h2>
38
+
<ul>
39
+
<li>Type your solution in the input box below the question.
40
+
<ul>
41
+
<li>Use <code>ip</code> variable to represent the sample input.</li>
42
+
<li>Any single valid Python expression will be accepted.</li>
43
+
<li>Some basic readline-like shortcuts are supported, for example <strong>Ctrl+u</strong>, <strong>Ctrl+k</strong>, <strong>Ctrl+w</strong>, etc</li>
44
+
</ul>
45
+
</li>
46
+
<li>Press <strong>Enter</strong> to execute the code.
47
+
<ul>
48
+
<li>Output would be displayed below the command box.</li>
49
+
<li>If the output matches the expected results, the solution box will turn <em>green</em> and a reference solution will also be shown.</li>
50
+
<li>Error messages due to exceptions will be displayed in <em>red</em>.</li>
51
+
</ul>
52
+
</li>
53
+
<li>Press <strong>Ctrl+p</strong> and <strong>Ctrl+n</strong> to navigate the questions list.</li>
54
+
<li>Press <strong>Ctrl+r</strong> to toggle between <strong>str</strong> and <strong>repr</strong> — helps to spot characters like tabs, newlines, backspaces, etc.</li>
55
+
<li>Press <strong>Ctrl+b</strong> to toggle between <strong>expected</strong> and <strong>actual</strong> — helps to debug incorrect solutions.</li>
56
+
<li>Press <strong>Ctrl+s</strong> to show the reference solution if you are unable to solve an exercise.</li>
57
+
<li>Press <strong>Ctrl+t</strong> to toggle between light and dark themes.</li>
58
+
<li>Press <strong>Ctrl+q</strong> to quit the app.</li>
59
+
<li>Press <strong>F1</strong> to view a detailed guide within the app itself and press <strong>F2</strong> to get back to the exercises.</li>
60
+
</ul>
61
+
<p>Your progress will be automatically saved and restored. Already answered questions will be skipped.</p>
62
+
<blockquote>
63
+
<p><img src="/images/warning.svg" alt="warning" /> There is no safeguard against the code you are executing. They are treated as if you executed them from a Python program.</p>
64
+
</blockquote>
65
+
<p>See <a href="https://github.com/learnbyexample/TUI-apps/blob/main/PyRegexExercises/app_guide.md">app_guide.md</a> for more detailed instructions.</p>
66
+
<br>
67
+
<h2 id="ebook">Ebook<a class="zola-anchor" href="#ebook" aria-label="Anchor link for: ebook">🔗</a></h2>
68
+
<p>See my <a href="https://github.com/learnbyexample/py_regular_expressions">Understanding Python re(gex)?</a> ebook to learn regular expressions with hundreds of examples and exercises.</p>
69
+
<br>
70
+
<h2 id="feedback">Feedback<a class="zola-anchor" href="#feedback" aria-label="Anchor link for: feedback">🔗</a></h2>
71
+
<p>I'd highly appreciate your feedback. Please file <a href="https://github.com/learnbyexample/TUI-apps/issues">an issue</a> if there are bugs, crashes, etc.</p>
72
+
<p>Hope you find this TUI app useful. Happy learning :)</p>
73
+
</content>
74
+
</entry>
10
75
<entry xml:lang="en">
11
76
<title>Vim tip 23: editing lines filtered by a pattern</title>
12
77
<published>2023-03-14T00:00:00+00:00</published>
@@ -4753,10 +4818,12 @@ Specifying a greater than <code>0</code> start index when using
4753
4818
<entry xml:lang="en">
4754
4819
<title>Improve your Python regex skills with 75 interactive exercises</title>
<content type="html"><p>Still confused about Python regular expressions? Grow your confidence with <a href="https://github.com/learnbyexample/py_regular_expressions">Understanding Python re(gex)?</a> ebook (FREE this month!) and an <a href="https://github.com/learnbyexample/py_regular_expressions/tree/master/interactive_exercises">interactive GUI app</a>.</p>
4824
+
<content type="html"><p><strong>(2023-03-20) Update:</strong> This <a href="https://github.com/learnbyexample/TUI-apps/blob/main/PyRegexExercises">TUI app</a> covers many more exercises compared to the GUI app discussed below.</p>
4825
+
<hr>
4826
+
<p>Still confused about Python regular expressions? Grow your confidence with <a href="https://github.com/learnbyexample/py_regular_expressions">Understanding Python re(gex)?</a> ebook (FREE this month!) and an <a href="https://github.com/learnbyexample/py_regular_expressions/tree/8433b34bd3f03662abac25c754a5ecf871712980/interactive_exercises">interactive GUI app</a>.</p>
4760
4827
<p>Inspired by <a href="https://adventofcode.com/">Advent of Code</a>, I'll also be posting <a href="https://twitter.com/learn_byexample/status/1465998844898918403">3 challenges per day on twitter</a> for 25 days.</p>
<h2 id="free-ebook">Free ebook<a class="zola-anchor" href="#free-ebook" aria-label="Anchor link for: free-ebook">🔗</a></h2>
@@ -4768,7 +4835,7 @@ Specifying a greater than <code>0</code> start index when using
4768
4835
<p>Or, you can use the <a href="https://learnbyexample.github.io/py_regular_expressions/">web version</a> if you prefer reading the book online.</p>
4769
4836
<br>
4770
4837
<h2 id="interactive-gui-app">Interactive GUI app<a class="zola-anchor" href="#interactive-gui-app" aria-label="Anchor link for: interactive-gui-app">🔗</a></h2>
4771
-
<p>Based on the <strong>Understanding Python re(gex)?</strong> book contents as well as the exercises, I made an <a href="https://github.com/learnbyexample/py_regular_expressions/tree/master/interactive_exercises">interactive GUI app</a> with 75 questions on <code>re.search</code>, <code>re.sub</code>, <code>re.split</code> and <code>re.findall</code> that'll test your understanding of anchors, alternation, grouping, escaping metacharacters, dot metacharacter, quantifiers, character class, grouping, lookarounds, flags, etc.</p>
4838
+
<p>Based on the <strong>Understanding Python re(gex)?</strong> book contents as well as the exercises, I made an <a href="https://github.com/learnbyexample/py_regular_expressions/tree/8433b34bd3f03662abac25c754a5ecf871712980/interactive_exercises">interactive GUI app</a> with 75 questions on <code>re.search</code>, <code>re.sub</code>, <code>re.split</code> and <code>re.findall</code> that'll test your understanding of anchors, alternation, grouping, escaping metacharacters, dot metacharacter, quantifiers, character class, grouping, lookarounds, flags, etc.</p>
4772
4839
<p>Here's some screenshots:</p>
4773
4840
<p align="center"><img src="/images/python_exercises/search.png" alt="Python exercise example for re.search" /></p>
4774
4841
<p align="center"><img src="/images/python_exercises/sub.png" alt="Python exercise example for re.sub" /></p>
0 commit comments