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
Copy file name to clipboardExpand all lines: interactive_exercises/README.md
+32-13Lines changed: 32 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,17 @@
1
1
## About
2
2
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.
4
4
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:
8
6
9
7
*`re.search()`
10
8
*`re.sub()`
11
9
*`re.findall()`
12
10
*`re.split()`
13
11
14
-
Here's a screenshot:
15
-
16
-
<palign="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:
19
13
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.
$ cd py_regular_expressions/interactive_exercises/
30
24
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
33
27
```
34
28
35
29
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.
36
30
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:
* 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
+
37
53
## TODO
38
54
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
0 commit comments