|
| 1 | +### Questions |
| 2 | + |
| 3 | +There are more than 100 exercises covering both the builtin `re` and third-party `regex` module. The initial questions cover the very basics of using `re` module functions. After that, you'll be required to use more and more regular expression features, roughly in the following order: |
| 4 | + |
| 5 | +* Anchors |
| 6 | +* Alternation and Grouping |
| 7 | +* Escaping metacharacters |
| 8 | +* Dot metacharacter and Quantifiers |
| 9 | +* Working with matched portions |
| 10 | +* Character class |
| 11 | +* Groupings and backreferences |
| 12 | +* Lookarounds |
| 13 | +* regex module |
| 14 | + |
| 15 | +There are two types of exercises: |
| 16 | + |
| 17 | +* search related functions like `search()`, `fullmatch()`, etc |
| 18 | +* other functions like `sub()`, `split()`, `findall()`, `finditer()`, etc |
| 19 | + |
| 20 | +### Solution Input box |
| 21 | + |
| 22 | +You can type the solution in the input box and press the **Enter** key to execute. For example, `re.search(r'cat', ip)` to check if `cat` is present in the input strings. `ip` is the variable that'll have the sample input (string or list of strings) for all the exercises. |
| 23 | + |
| 24 | +The input box will accept a single valid Python expression. Some of the exercises will require you to use list comprehensions. |
| 25 | + |
| 26 | +Some of the error types are caught. In such cases, the background color of the input box will change to *red* and the error message will be displayed below the box. Other errors might result in the app crashing. |
| 27 | + |
| 28 | +The input box will turn *green* if the entered code solves all the sample input strings. A reference solution box will appear below the table in such cases. You can press **Ctrl+s** to show the solution box whenever you want. |
| 29 | + |
| 30 | +For search related functions, the table below the input box will have a set of strings that should match and another set of strings that *shouldn't* match. These strings will be individually highlighted in *green* if the condition is satisfied and *red* otherwise. |
| 31 | + |
| 32 | +For some exercises, you might need to view the representation of sample strings instead of how they are displayed on the screen. For example, to spot characters like tabs, newlines, backspaces, etc. You can switch between these views using the **str** and **repr** radio buttons. Lists and dicts won't be affected by this option. You can also use the **Ctrl+r** shortcut to toggle these radio buttons. |
| 33 | + |
| 34 | +For other functions, the left column of the table will have a set of input with corresponding output in the right column. Each row will be highlighted in *green* or *red* based on the entered code satisfying the condition or not. You can switch between **expected** and **actual** radio buttons to view the expected and actual output in the right column. When you choose the **actual** option, the strings will be highlighted in *orange* if the output doesn't match the expected result. You can also use the **Ctrl+b** shortcut to toggle these radio buttons. |
| 35 | + |
| 36 | +Use appropriate anchors based on whether the term **string** or **line** is used in the question description. |
| 37 | + |
| 38 | +> **Warning:** There is no safeguard against the commands you have typed. They are treated as if you executed them from a Python program. |
| 39 | +
|
| 40 | +### Shortcuts |
| 41 | + |
| 42 | +You can either click the buttons using mouse or press the key combinations listed below: |
| 43 | + |
| 44 | +* **F1** view this guide |
| 45 | +* **F2** view exercises |
| 46 | +* **Ctrl+n** go the next question |
| 47 | +* **Ctrl+p** go the previous question |
| 48 | +* **Ctrl+s** show solution box |
| 49 | +* **Ctrl+r** toggle between **str** and **repr** |
| 50 | +* **Ctrl+b** toggle between **expected** and **actual** |
| 51 | +* **Ctrl+t** toggle the theme between **light** and **dark** modes |
| 52 | +* **Ctrl+c** or **Ctrl+q** quit the application |
| 53 | + |
| 54 | +Shortcuts for navigating and editing in the solution box are listed below: |
| 55 | + |
| 56 | +* Use mouse click to position the cursor anywhere you like |
| 57 | +* **←** move left by one character |
| 58 | +* **→** move right by one character |
| 59 | +* **Home** or **Ctrl+a** move to the start of the line |
| 60 | +* **End** or **Ctrl+e** move to the end of the line |
| 61 | +* **Ctrl+←** move to the start of the current/previous word |
| 62 | +* **Ctrl+→** move to the start of the next word |
| 63 | +* **Ctrl+w** delete till the start of the current/previous word |
| 64 | +* **Ctrl+f** delete till the start of the next word |
| 65 | +* **Ctrl+u** delete till the start of the line |
| 66 | +* **Ctrl+k** delete till the end of the line |
| 67 | +* **Backspace** or **Ctrl+h** delete character to the left of the cursor |
| 68 | +* **Delete** or **Ctrl+d** delete character under the cursor |
| 69 | +* **Enter** submit the code for execution |
| 70 | + |
| 71 | +### User progress |
| 72 | + |
| 73 | +Solutions you have typed are automatically saved in `user_progress.json` in the same directory as the script. This happens only when you press **Enter** to execute — navigating to another question and closing the app won't trigger the save logic. |
| 74 | + |
| 75 | +Radio button and theme choices are also saved. |
| 76 | + |
| 77 | +If you close the application and open it again, the first unsolved question will be displayed (i.e. already solved questions are skipped). |
| 78 | + |
| 79 | +If you use **Ctrl+s**, the solution *won't* be saved — you'll have to type and execute the code to be considered for saving the changes. |
| 80 | + |
| 81 | +Once you have solved a question, only a different correct solution can override the previously saved code. |
| 82 | + |
| 83 | +### Understanding Python re(gex)? |
| 84 | + |
| 85 | +The exercise questions in this app have been adapted from my ebook: [https://github.com/learnbyexample/py_regular_expressions](https://github.com/learnbyexample/py_regular_expressions) |
| 86 | + |
0 commit comments