Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 46dd6c7

Browse files
added more questions, updated README
1 parent 533fd9c commit 46dd6c7

File tree

5 files changed

+218
-91
lines changed

5 files changed

+218
-91
lines changed

‎interactive_exercises/README.md‎

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
11
## About
22

3-
This is a **work-in-progress** GUI app to help you practice Python regular expressions.
3+
A GUI app written in `tkinter`to help you practice Python regular expressions. The script has been tested for `python3.8` and above versions on Linux. This is likely to be functional on Windows/Mac as well.
44

5-
The script has been tested for `python3.9` version on Linux.
6-
7-
Currently, only a few questions have been added for the following functions:
5+
The following functions are currently supported:
86

97
* `re.search()`
108
* `re.sub()`
119
* `re.findall()`
1210
* `re.split()`
1311

14-
Here's a screenshot:
15-
16-
<p align="center">
17-
<img src="./regex_practice_example.png" />
18-
</p>
12+
The app automatically checks and highlights test strings based on user input. Here's a screenshot:
1913

20-
See [Exercises.md](https://github.com/learnbyexample/py_regular_expressions/blob/master/exercises/Exercises.md) for exercise questions from the **Python re(gex)?** book.
14+
<palign="center"> <imgsrc="./regex_practice_example.png" /> </p>
2115

2216
## Instructions
2317

@@ -28,15 +22,40 @@ $ git clone --depth=1 https://github.com/learnbyexample/py_regular_expressions
2822

2923
$ cd py_regular_expressions/interactive_exercises/
3024

31-
# use py instead of python3.9 for Windows
32-
$ python3.9 regex_practice.py
25+
# use py instead of python3 for Windows
26+
$ python3 regex_practice.py
3327
```
3428

3529
Your progress will be saved in a new file named `user_progress.json`. If you close the app and launch it again, already solved questions will be automatically skipped.
3630

31+
There are 75 questions in total. You can pass an integer value as command-line argument to directly open that particular question (this would also be skipped if it is already answered).
32+
33+
```bash
34+
# use py instead of python3 for Windows
35+
# opens 50th question
36+
$ python3 regex_practice.py 50
37+
```
38+
39+
## Notes
40+
41+
* Use appropriate anchors based on whether **string** or **line** is used in the question description.
42+
* By default, **visual string** radio option is active. It shows the test strings in the same way you'd see from the output of `print()` function. In case of `re.split()` and `re.findall()` functions, the output column shows the `list` return value. The **representation** radio choice shows the test strings using the `repr()` function, this is useful when the test strings contain whitespace characters.
43+
44+
Here's a screenshot to show the difference between these two options:
45+
46+
<p align="center"> <img src="./visual_string.png" /> </p>
47+
<p align="center"> <img src="./representation.png" /> </p>
48+
49+
* Backticks are used in the question descriptions to highlight search and replace terms.
50+
* User input entered via **Pattern** and **Replace** boxes will always be treated as raw-strings. For this reason, raw-strings are used for the reference solutions as well.
51+
* These exercise questions have been adapted from my [Python re(gex)?](https://github.com/learnbyexample/py_regular_expressions) ebook (free to read online). See [Exercises.md](https://github.com/learnbyexample/py_regular_expressions/blob/master/exercises/Exercises.md) for all the exercise questions from this book.
52+
3753
## TODO
3854

39-
* Add many more questions
55+
* Highlight portion of test strings that match the user pattern and show live output — these features will help in debugging solutions
56+
* Add support for arguments like `count` for `re.sub`, `maxsplit` for `re.split`, etc
57+
* Add support for `re.subn`, `re.fullmatch`, `re.finditer`, `re.Match`, etc
58+
* Add support for third-party [regex](https://pypi.org/project/regex/) module
4059
* Refactor
4160
* Add tests?
4261
* Etc

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /