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
<p><em>Above diagram created using <ahref="https://jex.im/regulex">Regulex</a></em></p>
161
161
<spanid="continue-reading"></span><br>
162
162
<p>This blog post gives an overview of regular expression syntax and features supported by JavaScript. Examples have been tested on Chrome/Chromium console (version 81+) and includes features not available in other browsers and platforms. Assume ASCII character set unless otherwise specified. This post is an excerpt from my <ahref="https://github.com/learnbyexample/learn_js_regexp">JavaScript RegExp</a> book.</p>
<h2id="javascript-regexp-book">JavaScript RegExp book<aclass="zola-anchor" href="#javascript-regexp-book" aria-label="Anchor link for: javascript-regexp-book">🔗</a></h2>
527
527
<p>Visit my repo <ahref="https://github.com/learnbyexample/learn_js_regexp">learn_js_regexp</a> for details about the book I wrote on JavaScript regular expressions. The ebook uses plenty of examples to explain the concepts from the basics and includes <ahref="https://github.com/learnbyexample/learn_js_regexp/blob/master/Exercises.md">exercises</a> to test your understanding. The cheatsheet and examples presented in this post are based on contents of this book.</p>
<p><em>Above visualization is a screenshot created using</em><ahref="https://www.debuggex.com">debuggex</a><em>for the pattern</em><code>r'\bpar(en|ro)?t\b'</code></p>
<h2id="next-step">Next step<aclass="zola-anchor" href="#next-step" aria-label="Anchor link for: next-step">🔗</a></h2>
171
177
<p>What to learn next is an often asked question. <ahref="https://www.reddit.com/r/learnpython/search?q=what+next&restrict_sr=on">Searching for <code>what next</code> on /r/learnpython</a> gives you too many results. Here's some more Q&A and articles on this topic:</p>
172
178
<ul>
173
179
<li><ahref="https://www.devdungeon.com/content/i-know-how-program-i-dont-know-what-program">I know how to program, but I don't know what to program</a></li>
<p>Another crucial aspect in the programming journey is knowing how to write tests. In bigger projects, usually there are separate engineers (often in much larger number than code developers) to test the code. Even in those cases, writing a few sanity test cases yourself can help you develop faster knowing that the changes aren't breaking basic functionality.</p>
215
221
<p>There's no single consensus on test methodologies. There is <ahref="https://en.wikipedia.org/wiki/Unit_testing">Unit testing</a>, <ahref="https://en.wikipedia.org/wiki/Integration_testing">Integration testing</a>, <ahref="https://en.wikipedia.org/wiki/Test-driven_development">Test-driven development</a> and so on. Often, a combination of these is used. These days, machine learning is also being considered to reduce the testing time, see <ahref="https://hacks.mozilla.org/2020/07/testing-firefox-more-efficiently-with-machine-learning/">Testing Firefox more efficiently with machine learning</a> for example.</p>
216
222
<p>When I start a project, I usually try to write the programs incrementally. Say I need to iterate over files from a directory. I will make sure that portion is working (usually with <code>print</code> statements), then add another feature — say file reading and test that and so on. This reduces the burden of testing a large program at once at the end. And depending upon the nature of the program, I'll add a few sanity tests at the end. For example, for my <ahref="https://github.com/learnbyexample/command_help">command_help</a> project, I copy pasted a few test runs of the program with different options and arguments into a separate file and wrote a program to perform these tests programmatically whenever the source code is modified.</p>
217
-
<p>For non-trivial projects, you'll usually end up needing frameworks like built-in module <code>unittest</code> or third-party modules like <code>pytest</code>. See <ahref="https://realpython.com/python-testing/">Getting started with testing in Python</a> and <ahref="https://calmcode.io/pytest/introduction.html">calmcode: pytest</a> for discussion on these topics.</p>
223
+
<p>For non-trivial projects, you'll usually end up needing frameworks like built-in module <code>unittest</code> or third-party modules like <code>pytest</code>. Here's some learning resources.</p>
224
+
<ul>
225
+
<li><ahref="https://realpython.com/python-testing/">Getting started with testing in Python</a></li>
<li><ahref="https://www.obeythetestinggoat.com/">obeythetestinggoat</a> — TDD for the Web, with Python, Selenium, Django, JavaScript and pals</li>
228
+
<li><ahref="https://testdriven.io/blog/modern-tdd/">Modern Test-Driven Development in Python</a> — TDD guide, has a real world application example</li>
229
+
</ul>
218
230
<br>
219
231
<h2id="intermediate-python-resources">Intermediate Python resources<aclass="zola-anchor" href="#intermediate-python-resources" aria-label="Anchor link for: intermediate-python-resources">🔗</a></h2>
<li><ahref="https://nostarch.com/seriouspython">Serious Python</a> — deployment, scalability, testing, and more</li>
244
+
<li><ahref="https://www.manning.com/books/practices-of-the-python-pro">Practices of the Python Pro</a> — learn to design professional-level, clean, easily maintainable software at scale, includes examples for software development best practices</li>
232
245
<li><ahref="https://pythonprogramming.net/">Pythonprogramming</a> — domain based topics like machine learning, game development, data analysis, web development, etc</li>
233
246
<li><ahref="https://www.youtube.com/user/schafer5/playlists">Youtube: Corey Schafer</a> — various topics for beginners to advanced users</li>
<p><em>Above visualization is a screenshot created using</em><ahref="https://www.debuggex.com">debuggex</a><em>for the pattern</em><code>r'\bpar(en|ro)?t\b'</code></p>
@@ -260,7 +260,9 @@ <h2 id="elements-that-define-a-regular-expression">Elements that define a regula
260
260
<tr><td><code>groupdict</code></td><td>method applied on a <code>re.Match</code> object</td></tr>
261
261
<tr><td></td><td>gives named capture group portions as a <code>dict</code></td></tr>
262
262
</tbody></table>
263
-
<p><code>\0</code> and <code>\100</code> onwards are considered as octal values, hence cannot be used as backreferences.</p>
263
+
<blockquote>
264
+
<p><imgsrc="/images/info.svg" alt="info" /><code>\0</code> and <code>\100</code> onwards are considered as octal values, hence cannot be used as backreferences.</p>
265
+
</blockquote>
264
266
<h2id="re-module-functions">re module functions<aclass="zola-anchor" href="#re-module-functions" aria-label="Anchor link for: re-module-functions">🔗</a></h2>
<h2id="python-re-gex-book">Python re(gex)? book<aclass="zola-anchor" href="#python-re-gex-book" aria-label="Anchor link for: python-re-gex-book">🔗</a></h2>
538
540
<p>Visit my repo <ahref="https://github.com/learnbyexample/py_regular_expressions">Python re(gex)?</a> for details about the book I wrote on Python regular expressions. The ebook uses plenty of examples to explain the concepts from the very beginning and step by step introduces more advanced concepts. The book also covers the <ahref="https://pypi.org/project/regex/">third party module regex</a>. The cheatsheet and examples presented in this post are based on contents of this book.</p>
539
541
<p>Use <ahref="https://leanpub.com/py_regex/c/P7erPYAm1386">this leanpub link</a> for a discounted price.</p>
0 commit comments