Skip to content

Commit 9a09c1d

Browse files
updated posts about python regex
1 parent 72ae7b4 commit 9a09c1d

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

atom.xml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<link href="https://learnbyexample.github.io/atom.xml" rel="self" type="application/atom+xml"/>
66
<link href="https://learnbyexample.github.io"/>
77
<generator uri="https://www.getzola.org/">Zola</generator>
8-
<updated>2023-10-04T00:00:00+00:00</updated>
8+
<updated>2023-10-12T00:00:00+00:00</updated>
99
<id>https://learnbyexample.github.io/atom.xml</id>
1010
<entry xml:lang="en">
1111
<title>Perl One-Liners Guide book announcement</title>
@@ -2319,7 +2319,7 @@
23192319
<entry xml:lang="en">
23202320
<title>Understanding Python re(gex)? book announcement</title>
23212321
<published>2023-01-30T00:00:00+00:00</published>
2322-
<updated>2023-01-31T00:00:00+00:00</updated>
2322+
<updated>2023-10-12T00:00:00+00:00</updated>
23232323
<link rel="alternate" href="https://learnbyexample.github.io/understanding-python-regex-announcement/" type="text/html"/>
23242324
<id>https://learnbyexample.github.io/understanding-python-regex-announcement/</id>
23252325
<content type="html">&lt;p&gt;Hello!&lt;&#x2F;p&gt;
@@ -2372,9 +2372,13 @@
23722372
&lt;&#x2F;ul&gt;
23732373
&lt;br&gt;
23742374
&lt;h2 id=&quot;re-gex-playground&quot;&gt;re(gex)? playground&lt;a class=&quot;zola-anchor&quot; href=&quot;#re-gex-playground&quot; aria-label=&quot;Anchor link for: re-gex-playground&quot;&gt;🔗&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
2375-
&lt;p&gt;To make it easier to experiment, I&#x27;m working on an interactive app. See &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;tree&#x2F;main&#x2F;PyRegexPlayground&quot;&gt;PyRegexPlayground&lt;&#x2F;a&gt; repo for installation instructions and usage guide. A sample screenshot is shown below:&lt;&#x2F;p&gt;
2375+
&lt;p&gt;To make it easier to experiment, I wrote on an interactive app. See &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;tree&#x2F;main&#x2F;PyRegexPlayground&quot;&gt;PyRegexPlayground&lt;&#x2F;a&gt; repo for installation instructions and usage guide. A sample screenshot is shown below:&lt;&#x2F;p&gt;
23762376
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;main&#x2F;PyRegexPlayground&#x2F;pyregex_finditer.png&quot; alt=&quot;Sample screenshot from the Playground screen&quot; loading=&quot;lazy&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
23772377
&lt;br&gt;
2378+
&lt;h2 id=&quot;re-gex-exercises&quot;&gt;re(gex)? exercises&lt;a class=&quot;zola-anchor&quot; href=&quot;#re-gex-exercises&quot; aria-label=&quot;Anchor link for: re-gex-exercises&quot;&gt;🔗&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
2379+
&lt;p&gt;I wrote another TUI app to help you solve exercises from this book interactively. See &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;tree&#x2F;main&#x2F;PyRegexExercises&quot;&gt;PyRegexExercises&lt;&#x2F;a&gt; repo for installation steps and &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;blob&#x2F;main&#x2F;PyRegexExercises&#x2F;app_guide.md&quot;&gt;app_guide.md&lt;&#x2F;a&gt; for instructions on using this app. Here&#x27;s a sample screenshot:&lt;&#x2F;p&gt;
2380+
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;main&#x2F;PyRegexExercises&#x2F;pyregex_exercises.png&quot; alt=&quot;Sample screenshot for Python regex exercises&quot; loading=&quot;lazy&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
2381+
&lt;br&gt;
23782382
&lt;h2 id=&quot;table-of-contents&quot;&gt;Table of Contents&lt;a class=&quot;zola-anchor&quot; href=&quot;#table-of-contents&quot; aria-label=&quot;Anchor link for: table-of-contents&quot;&gt;🔗&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
23792383
&lt;ol&gt;
23802384
&lt;li&gt;Preface&lt;&#x2F;li&gt;
@@ -9145,7 +9149,7 @@ no VAL is specified, the key will be given the value true.&lt;&#x2F;p&gt;
91459149
<entry xml:lang="en">
91469150
<title>Python regular expression cheatsheet and examples</title>
91479151
<published>2020-07-03T00:00:00+00:00</published>
9148-
<updated>2023-06-13T00:00:00+00:00</updated>
9152+
<updated>2023-10-12T00:00:00+00:00</updated>
91499153
<link rel="alternate" href="https://learnbyexample.github.io/python-regex-cheatsheet/" type="text/html"/>
91509154
<id>https://learnbyexample.github.io/python-regex-cheatsheet/</id>
91519155
<content type="html">&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;&#x2F;images&#x2F;books&#x2F;pyregex_example.png&quot; alt=&quot;pyregex example&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
@@ -9299,7 +9303,7 @@ no VAL is specified, the key will be given the value true.&lt;&#x2F;p&gt;
92999303
&lt;h2 id=&quot;regular-expression-examples&quot;&gt;Regular expression examples&lt;a class=&quot;zola-anchor&quot; href=&quot;#regular-expression-examples&quot; aria-label=&quot;Anchor link for: regular-expression-examples&quot;&gt;🔗&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
93009304
&lt;p&gt;As a good practice, always use &lt;strong&gt;raw strings&lt;&#x2F;strong&gt; to construct RE, unless other formats are required. This will avoid conflict between special meaning of the backslash character in RE and string literals.&lt;&#x2F;p&gt;
93019305
&lt;blockquote&gt;
9302-
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;info.svg&quot; alt=&quot;info&quot; &#x2F;&gt; I&#x27;m working on an interactive app to help you experiment with the examples presented below. See &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;tree&#x2F;main&#x2F;PyRegexPlayground&quot;&gt;PyRegexPlayground&lt;&#x2F;a&gt; repo for installation instructions and usage guide.&lt;&#x2F;p&gt;
9306+
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;info.svg&quot; alt=&quot;info&quot; &#x2F;&gt; I wrote an interactive TUI app to help you experiment with the examples presented below. See &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;tree&#x2F;main&#x2F;PyRegexPlayground&quot;&gt;PyRegexPlayground&lt;&#x2F;a&gt; repo for installation instructions and usage guide. See &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;TUI-apps&#x2F;tree&#x2F;main&#x2F;PyRegexExercises&quot;&gt;PyRegexExercises&lt;&#x2F;a&gt; repo for a TUI app with 100+ Python regex exercises.&lt;&#x2F;p&gt;
93039307
&lt;&#x2F;blockquote&gt;
93049308
&lt;ul&gt;
93059309
&lt;li&gt;examples for &lt;code&gt;re.search()&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
@@ -9554,7 +9558,7 @@ no VAL is specified, the key will be given the value true.&lt;&#x2F;p&gt;
95549558
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
95559559
&lt;br&gt;
95569560
&lt;h2 id=&quot;understanding-python-re-gex-book&quot;&gt;Understanding Python re(gex)? book&lt;a class=&quot;zola-anchor&quot; href=&quot;#understanding-python-re-gex-book&quot; aria-label=&quot;Anchor link for: understanding-python-re-gex-book&quot;&gt;🔗&lt;&#x2F;a&gt;&lt;&#x2F;h2&gt;
9557-
&lt;p&gt;Visit my GitHub repo &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;py_regular_expressions&quot;&gt;Understanding Python re(gex)?&lt;&#x2F;a&gt; for details about the book I wrote on Python regular expressions. The book uses plenty of examples to explain the concepts from the basics and introduces more advanced concepts step-by-step. The book also covers the &lt;a href=&quot;https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;regex&#x2F;&quot;&gt;third-party regex module&lt;&#x2F;a&gt;. The cheatsheet and examples presented in this post are based on contents of this book.&lt;&#x2F;p&gt;
9561+
&lt;p&gt;Visit my GitHub repo &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;py_regular_expressions&quot;&gt;Understanding Python re(gex)?&lt;&#x2F;a&gt; for details about the book I wrote on Python regular expressions. The book uses plenty of examples to explain the concepts from the basics and introduces more advanced concepts step-by-step. The book also covers the &lt;a href=&quot;https:&#x2F;&#x2F;pypi.org&#x2F;project&#x2F;regex&#x2F;&quot;&gt;third-party regex module&lt;&#x2F;a&gt;. The cheatsheet and examples presented in this post are based on the contents of this book.&lt;&#x2F;p&gt;
95589562
&lt;p align=&quot;center&quot;&gt;&lt;img src=&quot;https:&#x2F;&#x2F;raw.githubusercontent.com&#x2F;learnbyexample&#x2F;py_regular_expressions&#x2F;master&#x2F;images&#x2F;py_regex_ls.png&quot; width=&quot;640px&quot; height=&quot;360px&quot; alt=&quot;Understanding Python re(gex)? cover image&quot; loading=&quot;lazy&quot; &#x2F;&gt;&lt;&#x2F;p&gt;
95599563
</content>
95609564
</entry>

python-regex-cheatsheet/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</span><span>re.</span><span style=color:#5597d6;>findall</span><span>(pattern, string, </span><span style=color:#5597d6;>flags</span><span style=color:#72ab00;>=</span><span style=color:#b3933a;>0</span><span>)
88
</span><span>re.</span><span style=color:#5597d6;>finditer</span><span>(pattern, string, </span><span style=color:#5597d6;>flags</span><span style=color:#72ab00;>=</span><span style=color:#b3933a;>0</span><span>)
99
</span><span>re.</span><span style=color:#5597d6;>subn</span><span>(pattern, repl, string, </span><span style=color:#5597d6;>count</span><span style=color:#72ab00;>=</span><span style=color:#b3933a;>0</span><span>, </span><span style=color:#5597d6;>flags</span><span style=color:#72ab00;>=</span><span style=color:#b3933a;>0</span><span>)
10-
</span></code></pre><br><h2 id=regular-expression-examples>Regular expression examples<a aria-label="Anchor link for: regular-expression-examples" class=zola-anchor href=#regular-expression-examples>🔗</a></h2><p>As a good practice, always use <strong>raw strings</strong> to construct RE, unless other formats are required. This will avoid conflict between special meaning of the backslash character in RE and string literals.<blockquote><p><img alt=info src=/images/info.svg> I'm working on an interactive app to help you experiment with the examples presented below. See <a href=https://github.com/learnbyexample/TUI-apps/tree/main/PyRegexPlayground>PyRegexPlayground</a> repo for installation instructions and usage guide.</blockquote><ul><li>examples for <code>re.search()</code></ul><pre class=language-python data-lang=python style=background-color:#f5f5f5;color:#1f1f1f;><code class=language-python data-lang=python><span style=color:#72ab00;>>>> </span><span>sentence </span><span style=color:#72ab00;>= </span><span style=color:#d07711;>'This is a sample string'
10+
</span></code></pre><br><h2 id=regular-expression-examples>Regular expression examples<a aria-label="Anchor link for: regular-expression-examples" class=zola-anchor href=#regular-expression-examples>🔗</a></h2><p>As a good practice, always use <strong>raw strings</strong> to construct RE, unless other formats are required. This will avoid conflict between special meaning of the backslash character in RE and string literals.<blockquote><p><img alt=info src=/images/info.svg> I wrote an interactive TUI app to help you experiment with the examples presented below. See <a href=https://github.com/learnbyexample/TUI-apps/tree/main/PyRegexPlayground>PyRegexPlayground</a> repo for installation instructions and usage guide. See <a href=https://github.com/learnbyexample/TUI-apps/tree/main/PyRegexExercises>PyRegexExercises</a> repo for a TUI app with 100+ Python regex exercises.</blockquote><ul><li>examples for <code>re.search()</code></ul><pre class=language-python data-lang=python style=background-color:#f5f5f5;color:#1f1f1f;><code class=language-python data-lang=python><span style=color:#72ab00;>>>> </span><span>sentence </span><span style=color:#72ab00;>= </span><span style=color:#d07711;>'This is a sample string'
1111
</span><span>
1212
</span><span style=color:#7f8989;># need to load the re module before use
1313
</span><span style=color:#72ab00;>>>> import </span><span>re
@@ -209,4 +209,4 @@
209209
</span><span style=color:#d07711;>'a+b - foo + c</span><span style=color:#aeb52b;>%d</span><span style=color:#d07711;>'
210210
</span><span style=color:#72ab00;>>>> </span><span>pat.</span><span style=color:#5597d6;>sub</span><span>(</span><span style=color:#d07711;>''</span><span>, </span><span style=color:#d07711;>'Hi there(greeting). Nice day(a(b)'</span><span>)
211211
</span><span style=color:#d07711;>'Hi there. Nice day'
212-
</span></code></pre><br><h2 id=understanding-python-re-gex-book>Understanding Python re(gex)? book<a aria-label="Anchor link for: understanding-python-re-gex-book" class=zola-anchor href=#understanding-python-re-gex-book>🔗</a></h2><p>Visit my GitHub repo <a href=https://github.com/learnbyexample/py_regular_expressions>Understanding Python re(gex)?</a> for details about the book I wrote on Python regular expressions. The book uses plenty of examples to explain the concepts from the basics and introduces more advanced concepts step-by-step. The book also covers the <a href=https://pypi.org/project/regex/>third-party regex module</a>. The cheatsheet and examples presented in this post are based on contents of this book.<p align=center><img alt="Understanding Python re(gex)? cover image" height=360px loading=lazy src=https://raw.githubusercontent.com/learnbyexample/py_regular_expressions/master/images/py_regex_ls.png width=640px></div><div class=post-footer><div class=post-tags><a href=https://learnbyexample.github.io/tags/python/>#python</a><a href=https://learnbyexample.github.io/tags/regular-expressions/>#regular-expressions</a><a href=https://learnbyexample.github.io/tags/cheatsheet/>#cheatsheet</a><a href=https://learnbyexample.github.io/tags/re-module/>#re-module</a><a href=https://learnbyexample.github.io/tags/examples/>#examples</a></div><hr color=#e6e6e6><div class=post-nav><p><a class=previous href=https://learnbyexample.github.io/javascript-regexp-cheatsheet/>← JavaScript regular expressions cheatsheet and examples</a><br><p><a class=next href=https://learnbyexample.github.io/python-regex-book-version2/>Example driven book on Python regular expressions →</a><br></div><hr color=#e6e6e6><p>📰 Use <a href=https://learnbyexample.github.io/atom.xml>this link</a> for the Atom feed. <br> ✅ Follow me on <a href=https://twitter.com/learn_byexample>Twitter</a>, <a href=https://github.com/learnbyexample>GitHub</a> and <a href=https://www.youtube.com/c/learnbyexample42>Youtube</a> for interesting tech nuggets. <br> 📧 Subscribe to <a href=https://learnbyexample.gumroad.com/l/learnbyexample-weekly>learnbyexample weekly</a> for programming resources, tips, tools, free ebooks and more (free newsletter, delivered every Friday).<hr color=#e6e6e6></div></article></div></main></div><script src=https://learnbyexample.github.io/even.js></script>
212+
</span></code></pre><br><h2 id=understanding-python-re-gex-book>Understanding Python re(gex)? book<a aria-label="Anchor link for: understanding-python-re-gex-book" class=zola-anchor href=#understanding-python-re-gex-book>🔗</a></h2><p>Visit my GitHub repo <a href=https://github.com/learnbyexample/py_regular_expressions>Understanding Python re(gex)?</a> for details about the book I wrote on Python regular expressions. The book uses plenty of examples to explain the concepts from the basics and introduces more advanced concepts step-by-step. The book also covers the <a href=https://pypi.org/project/regex/>third-party regex module</a>. The cheatsheet and examples presented in this post are based on the contents of this book.<p align=center><img alt="Understanding Python re(gex)? cover image" height=360px loading=lazy src=https://raw.githubusercontent.com/learnbyexample/py_regular_expressions/master/images/py_regex_ls.png width=640px></div><div class=post-footer><div class=post-tags><a href=https://learnbyexample.github.io/tags/python/>#python</a><a href=https://learnbyexample.github.io/tags/regular-expressions/>#regular-expressions</a><a href=https://learnbyexample.github.io/tags/cheatsheet/>#cheatsheet</a><a href=https://learnbyexample.github.io/tags/re-module/>#re-module</a><a href=https://learnbyexample.github.io/tags/examples/>#examples</a></div><hr color=#e6e6e6><div class=post-nav><p><a class=previous href=https://learnbyexample.github.io/javascript-regexp-cheatsheet/>← JavaScript regular expressions cheatsheet and examples</a><br><p><a class=next href=https://learnbyexample.github.io/python-regex-book-version2/>Example driven book on Python regular expressions →</a><br></div><hr color=#e6e6e6><p>📰 Use <a href=https://learnbyexample.github.io/atom.xml>this link</a> for the Atom feed. <br> ✅ Follow me on <a href=https://twitter.com/learn_byexample>Twitter</a>, <a href=https://github.com/learnbyexample>GitHub</a> and <a href=https://www.youtube.com/c/learnbyexample42>Youtube</a> for interesting tech nuggets. <br> 📧 Subscribe to <a href=https://learnbyexample.gumroad.com/l/learnbyexample-weekly>learnbyexample weekly</a> for programming resources, tips, tools, free ebooks and more (free newsletter, delivered every Friday).<hr color=#e6e6e6></div></article></div></main></div><script src=https://learnbyexample.github.io/even.js></script>

sitemap.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@
211211
</url>
212212
<url>
213213
<loc>https://learnbyexample.github.io/python-regex-cheatsheet/</loc>
214-
<lastmod>2023-06-13</lastmod>
214+
<lastmod>2023-10-12</lastmod>
215215
</url>
216216
<url>
217217
<loc>https://learnbyexample.github.io/python-regex-playground/</loc>
@@ -847,7 +847,7 @@
847847
</url>
848848
<url>
849849
<loc>https://learnbyexample.github.io/understanding-python-regex-announcement/</loc>
850-
<lastmod>2023-01-31</lastmod>
850+
<lastmod>2023-10-12</lastmod>
851851
</url>
852852
<url>
853853
<loc>https://learnbyexample.github.io/vim-reference-guide-announcement/</loc>

0 commit comments

Comments
 (0)