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 d6aec66

Browse files
updates for version 4.1
1 parent 9740ac0 commit d6aec66

File tree

7 files changed

+26
-12
lines changed

7 files changed

+26
-12
lines changed

‎Version_changes.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<br>
22

3+
### 4.1
4+
5+
* Updated details for **re(gex)? playground** app
6+
* Added section for **re(gex)? exercises** app
7+
* Better sample input for one of the exercises
8+
* Corrected one of the exercise solutions and added alternate solution for another exercise
9+
10+
<br>
11+
312
### 4.0
413

514
* Python version updated to 3.11

‎exercises/Exercise_solutions.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ False
150150
**c)** For the given input list, filter all elements that contain `42` surrounded by word characters.
151151

152152
```ruby
153-
>>> words = ['hi42bye', 'nice1423', 'bad42', 'cool_42a', 'fake42', '_42_']
153+
>>> words = ['hi42bye', 'nice1423', 'bad42', 'cool_42a', '42fake', '_42_']
154154

155155
>>> [w for w in words if re.search(r'\B42\B', w)]
156156
['hi42bye', 'nice1423', 'cool_42a', '_42_']
@@ -1308,7 +1308,7 @@ took 22
13081308
```ruby
13091309
>>> ip = '12 ab32.4 go 5 2. 46.42 5'
13101310

1311-
>>> re.findall(r'\d+(?=\.\d+)', ip)
1311+
>>> re.findall(r'\d+(?=\.\d)', ip)
13121312
['32', '46']
13131313
```
13141314

@@ -1744,6 +1744,7 @@ Refer to the [exercises folder](https://github.com/learnbyexample/py_regular_exp
17441744
>>> s1 = 'Sample123string42with777numbers'
17451745
>>> s2 = '12apples'
17461746

1747+
# can also use: r'(?:.*\D)?\K(\d+)'
17471748
# r'(\d+)(?!.*\d)' is an alternate solution that'll also work with 're' module
17481749
>>> pat = regex.compile(r'.*\K(?<!\d)(\d+)')
17491750

‎exercises/Exercises.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ False
154154
**c)** For the given input list, filter all elements that contain `42` surrounded by word characters.
155155

156156
```ruby
157-
>>> words = ['hi42bye', 'nice1423', 'bad42', 'cool_42a', 'fake42', '_42_']
157+
>>> words = ['hi42bye', 'nice1423', 'bad42', 'cool_42a', '42fake', '_42_']
158158

159159
>>> [w for w in words if re.search()] ##### add your solution here
160160
['hi42bye', 'nice1423', 'cool_42a', '_42_']

‎images/pyregex_exercises.png‎

23 KB
Loading[フレーム]

‎images/pyregex_playground.png‎

-695 Bytes
Loading[フレーム]

‎py_regex.md‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Resources mentioned in Acknowledgements section above are available under origin
6565

6666
## Book version
6767

68-
4.0
68+
4.1
6969

7070
See [Version_changes.md](https://github.com/learnbyexample/py_regular_expressions/blob/master/Version_changes.md) to track changes across book versions.
7171

@@ -312,7 +312,7 @@ False
312312

313313
## re(gex)? playground
314314

315-
To make it easier to experiment, I'm working on an interactive app. See [PyRegexPlayground](https://github.com/learnbyexample/TUI-apps/tree/main/PyRegexPlayground) repo for installation instructions and usage guide. A sample screenshot is shown below:
315+
To make it easier to experiment, I wrote an interactive TUI app. See [PyRegexPlayground](https://github.com/learnbyexample/TUI-apps/tree/main/PyRegexPlayground) repo for installation instructions and usage guide. A sample screenshot is shown below:
316316

317317
![Python re(gex)? playground](images/pyregex_playground.png)
318318

@@ -749,7 +749,7 @@ False
749749
**c)** For the given input list, filter all elements that contain `42` surrounded by word characters.
750750

751751
```ruby
752-
>>> words = ['hi42bye', 'nice1423', 'bad42', 'cool_42a', 'fake42', '_42_']
752+
>>> words = ['hi42bye', 'nice1423', 'bad42', 'cool_42a', '42fake', '_42_']
753753

754754
>>> [w for w in words if re.search()] ##### add your solution here
755755
['hi42bye', 'nice1423', 'cool_42a', '_42_']
@@ -1891,19 +1891,23 @@ The below image is a screenshot from this link — [debuggex: `r'\bpar(en|ro)?t\
18911891

18921892
## re(gex)? playground
18931893

1894-
As already mentioned in the introduction chapter, I'm also working on an interactive app. See [PyRegexPlayground](https://github.com/learnbyexample/TUI-apps/tree/main/PyRegexPlayground) repo for installation instructions and usage guide.
1894+
As already mentioned in the introduction chapter, I wrote an interactive TUI app for interactive practice. See [PyRegexPlayground](https://github.com/learnbyexample/TUI-apps/tree/main/PyRegexPlayground) repo for installation instructions and usage guide.
18951895

1896-
## regexcrossword
1896+
## re(gex)? exercises
18971897

1898-
For practice, [regexcrossword](https://regexcrossword.com/) is often recommended. It only supports JavaScript, so some of the puzzles may not work the same with Python syntax. See [regexcrossword: howtoplay](https://regexcrossword.com/howtoplay) for help.
1898+
I wrote another TUI app to help you solve exercises from this book interactively. See [PyRegexExercises](https://github.com/learnbyexample/TUI-apps/tree/main/PyRegexExercises) repo for installation steps and [app_guide.md](https://github.com/learnbyexample/TUI-apps/blob/main/PyRegexExercises/app_guide.md) for instructions on using this app.
1899+
1900+
Here's a sample screenshot:
18991901

1900-
The below image is a screenshot from this link — [regexcrossword: tutorial puzzle 5](https://regexcrossword.com/challenges/tutorial/puzzles/5)
1902+
![PyRegexExercises example](images/pyregex_exercises.png)
19011903

1902-
![regexcrossword example](images/regexcrossword.png)
1904+
## regexcrossword
1905+
1906+
For practice, [regexcrossword](https://regexcrossword.com/) is often recommended. It only supports JavaScript, so some of the puzzles may not work the same with Python syntax. See [regexcrossword: howtoplay](https://regexcrossword.com/howtoplay) for help.
19031907

19041908
## Summary
19051909

1906-
This chapter briefly presented three online tools that can help you with understanding and interactively solving/debugging regular expressions. Syntax and features can vary, sometimes significantly, between various tools and programming languages. So, ensure that the program you are using supports the flavor of regular expressions you are using.
1910+
This chapter briefly presented tools that can help you with understanding and interactively solving/debugging regular expressions. Syntax and features can vary, sometimes significantly, between various tools and programming languages. So, ensure that the program you are using supports the flavor of regular expressions you are using.
19071911

19081912
# Working with matched portions
19091913

‎sample_chapters/py_regex_sample.pdf‎

-756 Bytes
Binary file not shown.

0 commit comments

Comments
(0)

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