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: PyRegexPlayground/README.md
+15-9
Original file line number
Diff line number
Diff line change
@@ -2,25 +2,31 @@
2
2
3
3
This TUI application is intended as an interactive playground for Python Regular Expressions. The app also includes a comprehensive cheatsheet and several interactive examples.
4
4
5
-
> **Warning**
6
-
> Work in progress.
7
-
8
5
# Installation
9
6
10
-
You'll need to install `textual` first. See [Textual documentation](https://textual.textualize.io/getting_started/) for more details about installation. After that, you can clone this repository and run the `pyregex_playground.py` script. Adjust terminal dimensions as needed. Example instructions are shown below, adjust them based on your preferences and OS.
7
+
This app is available on PyPI as [regexplayground](https://pypi.org/project/regexplayground/). Example installation instructions are shown below, adjust them based on your preferences and OS.
To run the app without having to enter the virtual environment again, add this alias to `.bashrc` (or equivalent):
21
+
22
+
```bash
23
+
# you'll have to change the path
24
+
alias regexplayground='/path/to/textual_apps/bin/regexplayground'
21
25
```
22
26
23
-
Here are some sample screenshots:
27
+
As an alternative, you can install `textual` (see [Textual documentation](https://textual.textualize.io/getting_started/) for more details), clone this repository and run the `pyregex_playground.py` file.
28
+
29
+
Adjust the terminal dimensions for the widgets to appear properly, for example 84x25 (characters x lines). Here are some sample screenshots:
24
30
25
31
<palign="center"><imgsrc="./pyregex_finditer.png"alt="Sample screenshot from the Playground screen" /></p>
Copy file name to clipboardExpand all lines: PyRegexPlayground/app_guide.md
+18-1
Original file line number
Diff line number
Diff line change
@@ -6,10 +6,27 @@ You can type the search pattern in the **Compile** input box and press the **Ent
6
6
7
7
The compiled pattern is available via the `pat` variable and you can use `ip` to refer to the input string. You can transform or extract data by typing appropriate expression in the **Action** box. For example, `pat.sub(r'(\g<0>)', ip)` will add parenthesis around the matching portions.
8
8
9
-
The input string is obtained from the `ip.txt` file. You can change contents of this file and press **Ctrl+i** to update the `ip` variable. You'll have to press **Enter** again to update the results for the changed data.
9
+
You can skip the Compile box and directly use the Action box too. For example, `[m.span() for m in re.finditer(r'\d+', ip)]` to get the location of all the matching portions.
10
10
11
11
> **Warning:** There is no safeguard against the commands you have typed. They are treated as if you executed them from a Python program.
12
12
13
+
### Changing ip
14
+
15
+
The input string is obtained from the `ip.txt` file. You can change contents of this file and press **Ctrl+p** to update the `ip` variable. You'll have to press **Enter** again to update the results for the changed data.
16
+
17
+
If you cloned the repo, you'd be able to easily spot the `ip.txt` file in the same directory as the script you are running. If you installed the app via the `pip` command in a virtual environment, you'll have to locate this file first. For example:
This convoluted procedure will be simplified in the future by adding a widget for accepting multiline user input.
29
+
13
30
### Handling errors
14
31
15
32
Some of the error types are caught. In such cases, the background color of the input boxes will change to red and the error message will be displayed below the corresponding box. Other errors might result in the app crashing.
0 commit comments