<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ivan Rahn on Medium]]></title>
        <description><![CDATA[Stories by Ivan Rahn on Medium]]></description>
        <link>https://medium.com/@ivanrahn?source=rss-6cec31271ac4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BcpwpVhtqZYt-0YHFnhYLw.png</url>
            <title>Stories by Ivan Rahn on Medium</title>
            <link>https://medium.com/@ivanrahn?source=rss-6cec31271ac4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 11:28:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ivanrahn/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Adventures of /PeterThePatternTrainer/]]></title>
            <link>https://medium.com/@ivanrahn/adventures-of-peterthepatterntrainer-eda48d2fa138?source=rss-6cec31271ac4------2</link>
            <guid isPermaLink="false">https://medium.com/p/eda48d2fa138</guid>
            <category><![CDATA[regex]]></category>
            <category><![CDATA[regular-expressions]]></category>
            <dc:creator><![CDATA[Ivan Rahn]]></dc:creator>
            <pubDate>Mon, 07 Jan 2019 21:01:00 GMT</pubDate>
            <atom:updated>2019-01-07T21:01:00.827Z</atom:updated>
            <content:encoded><![CDATA[<h4>A lightning talk about RegEx at CoderAcademy.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*63xWnOnV1E9mCzHZCs5L5Q.jpeg" /></figure><h3>Once upon a time there lived a regex called P<strong>eter</strong>.</h3><p>He was just an average little regex in the world of JavaScript.<br>He could’ve been created like any other regex pattern from <strong>a literal</strong>:</p><pre>let Peter = /<strong>༼ つ ◕_◕ ༽つ</strong>/</pre><p>Or by calling a <strong>regex constructor function</strong>:</p><pre>let Peter = new RegExp(/<strong>༼ つ ◕_◕ ༽つ</strong>/)</pre><pre>               or</pre><pre>let Peter = new RegExp(`<strong>༼ つ ◕_◕ ༽つ</strong>`)</pre><p>And like all the other young regular expressions he had a dream:</p><blockquote>He wanted be the very best, like no one ever was…</blockquote><blockquote>To catch all the strings was his real test,</blockquote><blockquote>To match them was his cause…</blockquote><p>So he set on a journey to fill out his ‘<em>patterndex’</em> with all the strings he can encounter, and to aid him on his journey he had a bag full of <strong><em>‘patternBall’</em></strong><em>s</em><br>(a.k.a. <strong>special characters</strong>).</p><p>Walking down the hiking trail away from his hometown Peter heard a rustling sound in the tall grass and decided to check it out.</p><p>Suddenly a wild <strong>string of numbers</strong> appeared!</p><pre>let wildString = &#39;123&#39;</pre><blockquote>“This pattern is no match for me!” - cried out Peter.</blockquote><p>And indeed it wasn’t.</p><pre>wildString.match(Peter) // =&gt; null</pre><p>Excited, Peter dug into his bag of <strong><em>‘patternBall’</em></strong><em>s</em> and threw the first one with some numbers on it.</p><pre>let patternBall = new RegExp(/<strong>1</strong>/)</pre><p>Hooray, it’s a match!</p><pre>wildString.match(patternBall) // =&gt; <br>[<strong>&quot;1&quot;</strong>, index: 0, input: &quot;123&quot;, groups: undefined]</pre><p>But it wasn’t very effective, as <strong>it couldn’t capture the whole string</strong>!</p><p>Peter scratched his head and looked into his bag. Lucky for him, he had another ‘<strong><em>patternBall’</em></strong> that matched the string.</p><pre>patternBall = new RegExp(/<strong>123</strong>/)<br>wildString.match(patternBall) // =&gt;<br>[<strong>&quot;123&quot;</strong>, index: 0, input: &quot;123&quot;, groups: undefined]</pre><p>Lo and behold, the string is a match! <br>His ‘<em>patterndex’</em> was updated with the strings information as its first entry.</p><p>Peter, being the smart little pattern trainer, quickly realised that it was just a stroke of luck the string didn’t escape and that he can’t just throw random <strong><em>‘patternBalls’</em></strong> at strings and expect them to just match.</p><p>He needs to be prepared for any string that may come his way, and practice combining the characters in the <strong><em>‘patternBalls’ </em></strong>.</p><p>Spotting a patch of tall grass with lots of strings roaming around Peter decides to camp for a while and examine the characters available to him.</p><h3>Alternation</h3><p>The first group of characters that captured Peter’s attention is labeled alternation characters.</p><h4>First of them being an <strong>or </strong>operator ( | ).</h4><pre>let alternationBall = new RegExp(/<strong>a|b</strong>/)<br>&quot;a&quot;.match(alternationBall) // =&gt; <br>[<strong>&quot;a&quot;</strong>, index: 0, input: &quot;a&quot;, groups: undefined]</pre><pre>&quot;b&quot;.match(alternationBall) // =&gt;<br>[<strong>&quot;b&quot;</strong>, index: 0, input: &quot;b&quot;, groups: undefined]</pre><p>Wow, this can help Peter prepare for a whole range of encounters! Peter quickly makes a <strong><em>‘patternBall’</em></strong> to match <strong>any number character</strong>:</p><pre>let numberBall = new RegExp(/0|1|2|3|4|5|6|7|8|9/)</pre><blockquote>“Hm, but it seems to be an unnecessarily complicated pattern, maybe there is a way to shorten it?” — Peter says to himself and examines the next characters</blockquote><h4>The square brackets ( [ ] ) and dash symbol ( — ).</h4><p><strong>[] — </strong>The square brackets allow the pattern to match anything that is placed between them, so the <strong><em>‘patternBalls’</em></strong> for <strong>any number</strong> can now be constructed like this:</p><pre>let numberBall = new RegExp(/[0123456789]/)</pre><p>This seems to be a bit more manageable!</p><p>But what does the dash character do?<br><strong>( — ) — </strong>It allows Peter to create sets of characters!<br>Now the<strong><em> ‘numberBall’</em></strong> can be even easier to construct:</p><pre>let numberBall = new RegExp(/[0-9]/)</pre><p>That is a lot shorter than the original <strong><em>‘numberBall’</em></strong> Peter made!<br>Moreover, after a bit of experimentation, Peter constructs a ball to match <strong>any lowercase letter:</strong></p><pre>let lowercaseBall = new RegExp(/[a-z]/)</pre><p><strong>Any uppercase letter:</strong></p><pre>let uppercaseBall = new RegExp(/[A-Z]/)</pre><p>And to top it off, <strong>any upper or lowercase letter or any digit!:</strong></p><pre>let anycaseBall = new RegExp(/[0-9a-zA-Z]/)</pre><p>Wow, that makes it quite easy to construct a pattern! But there is an even shorter way to do it with a help of <strong>character sets.</strong></p><h3>Character sets</h3><h4>The most commonly used ones are the following:</h4><p><strong>\d </strong>— equivalent to [0–9] and will match any digit,</p><p><strong>\w</strong> — matches any alphanumeric character (any letter, digit or underscore),</p><p><strong>\s </strong>— matches any whitespace character (space, carriage return, new line etc.</p><p>Now the last <strong><em>‘patternBall’</em></strong> can be rewritten as:</p><pre>alphaBall = /\w/</pre><p>Writing a character set <strong>with a capital letter</strong> will reverse it, e.g. \D will match any non-digit character.</p><blockquote>“This is all very exciting,” thinks Peter, “but what if I encounter a string longer than a single character?”</blockquote><h3>Quantifiers</h3><p>The next set of character Peter examines, called “<strong>quantifiers”,</strong> specify how many times <strong>the pattern</strong> preceding the quantifier will match the <strong><em>‘patternBall’</em></strong>.</p><h4>Perter finds three quantifier characters:</h4><p><strong>( ? )</strong> — allows the ball to match with 0 or 1 of the preceding character,</p><p><strong>( + ) </strong>— 1 or more,</p><p><strong>( * ) </strong>— 0 or more.</p><p>Deciding to try out and practice using these characters Peter heads out deeper into the tall grass. Locating a patch with a lot of letter strings, Peter prepares 3 patternBalls.</p><ol><li><strong><em>‘abcBall’</em> will match the string:</strong><br>if “a” appears zero or once (0 or 1 time), followed by “bc”</li></ol><pre>abcBall = /a?bc/ </pre><p>Let’s see what strings Peter can catch with <strong><em>‘abcBall’</em></strong>.</p><pre>1) &quot;abc&quot;.match(abcBall) // =&gt;<br>[<strong>&quot;abc&quot;</strong>, index: 0, input: &quot;abc&quot;, groups: undefined]</pre><pre>2) &quot;bc&quot;.match(abcBall) // =&gt;<br>[<strong>&quot;bc&quot;</strong>, index: 0, input: &quot;bc&quot;, groups: undefined]</pre><pre>3) &quot;ac&quot;.match(abcBall) // =&gt;<br><strong>null</strong></pre><p>As Peter expected, the first and second strings where captured in full, but it was no match for the third string, as the <strong><em>‘abcBall’</em></strong> requires character “b” before “c”.</p><p>2. <strong><em>‘bbcBall’</em> will match the string:</strong><br>if “a” appears zero or once (0 or 1 time),<br>followed by 1 or more “b”, followed by “c”</p><pre>bbcBall = /a?b+c/</pre><blockquote>Let’s try it out!</blockquote><pre>1) &quot;abbc&quot;.match(bbcBall) // =&gt;<br>[<strong>&quot;abbc&quot;</strong>, index: 0, input: &quot;abbc&quot;, groups: undefined]</pre><pre>2) &quot;bbbbbc&quot;.match(bbcBall) // =&gt;<br>[<strong>&quot;bbbbbc&quot;</strong>, index: 0, input: &quot;bbbbbc&quot;, groups: undefined]</pre><pre>3) &quot;ac&quot;.match(abbbBall) // =&gt;<br><strong>null</strong></pre><p>This time the ball can match 1 or more “b”.</p><p>3. <strong><em>‘bBall’</em> will match the string:</strong><br>if “a” appears zero or once (0 or 1 time),<br>followed by 1 or more “b”, <br>followed by 0 or more “c”</p><pre>bBall = /a?b+c*/</pre><blockquote>And test!</blockquote><pre>1) &quot;abbcccc&quot;.match(bBall) // =&gt;<br>[<strong>&quot;abbcccc&quot;</strong>, index: 0, input: &quot;abbcccc&quot;, groups: undefined]</pre><pre>2) &quot;b&quot;.match(bBall) // =&gt;<br>[<strong>&quot;b&quot;</strong>, index: 0, input: &quot;b&quot;, groups: undefined]</pre><p>So the only required character is actually “b”.</p><p>The <strong><em>‘bBall’ </em></strong>will always be a match for strings that “b” appears at least once, while “c” can occur 0 or more times.</p><p>Having filled the ‘<em>patterndex’</em> with quite a few strings, Peter decides it is time to be more specific with what he catches. There are a lot of strings out there, but sometimes a pattern trainer needs only a specific part of the string to complete the entry in the ‘<em>patterndex’</em>.</p><pre>badString = &quot;bad!string&quot;</pre><p>How can Peter match only the <strong><em>“string” </em></strong>part of the <strong><em>“badString”</em></strong> ?<br>It wouldn’t be possible with the characters Peter used so far:</p><pre>patternBall = /\w+/<br>badString.match(patternBall) // =&gt; <br>[<strong>&quot;bad&quot;</strong>, index: 0, input: &quot;bad!string&quot;, groups: undefined]</pre><blockquote>Reminder:<br>\w will not be a match for characters that are not alphanumerics.</blockquote><h3>Anchors</h3><p>Peter can specify the position of the pattern he is matching using the anchor characters:</p><p><strong>( $ )</strong> — Applying this symbol <strong>after</strong> the pattern will tell the ball to look for the match at the <strong>end of the string</strong>,</p><blockquote>Let’s try this again</blockquote><pre>dollarBall = /\w+$/<br>badString.match(dollarBall) // =&gt; <br>[<strong>&quot;string&quot;</strong>, index: 4, input: &quot;bad!string&quot;, groups: undefined]</pre><p><strong>(^)</strong> — In a similar way, when this caret symbol ( ^ ) is placed in front of the pattern, our <strong><em>‘patternBall’ </em></strong>will only be a match if the pattern occurs at the <strong>beginning of the string</strong>:</p><pre>badString = &quot;123badstring&quot;<br>caretBall = /^[a-z]/<br>badString.match(caretBall) // =&gt;<br>null</pre><blockquote>It wasn’t a match because that string started with digits.</blockquote><p>Now, when both anchors are combined, the ‘<strong><em>patternBall’ </em></strong>will capture the string only if it is a complete match from the beginning to the end of the string. Here are examples without the anchors:</p><pre>patternBall = /capture/<br>string = &quot;do not capture me&quot;<br>string.match(patternBall) // =&gt;<br>[<strong>&quot;capture&quot;</strong>, index: 7, input: &quot;do not capture me&quot;, groups: undefined]</pre><p>And with the anchors:</p><pre>patternBall = /<strong>^</strong>capture<strong>$</strong>/<br>string = &quot;do not capture me&quot;<br>string.match(patternBall) // =&gt; <br>null</pre><p>There is no match as this ‘<strong><em>patternBall’</em></strong> is only capable of capturing a string that matches “capture” from the beginning to the end.</p><p>Wow, what a busy day for Peter! Having examined a lot of the characters on the ‘<strong><em>patternBalls’</em></strong> and practiced capturing the strings, Peter feels that he can now be qualified as a pattern trainer and continue his journey.</p><p>Obviously, he can not be called a master yet, there are still a few techniques he hasn’t mastered like more <strong>quantifiers</strong>, <strong>lookaheads</strong>, <strong>capture groups</strong>, and <strong>negated character sets</strong>, but this is something he can learn some other day.</p><blockquote>Stay tuned for chapter 2 of Peter’s adventures to find out how he learned to capture and validate legendary password strings!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eda48d2fa138" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Going down the rabbit hole of learning how to code, with a plan.]]></title>
            <link>https://medium.com/@ivanrahn/going-down-the-rabbit-hole-of-learning-how-to-code-with-a-plan-1be1726e7fde?source=rss-6cec31271ac4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1be1726e7fde</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[codingbootcamp]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[80-20-rule]]></category>
            <category><![CDATA[learning]]></category>
            <dc:creator><![CDATA[Ivan Rahn]]></dc:creator>
            <pubDate>Tue, 16 Oct 2018 21:01:05 GMT</pubDate>
            <atom:updated>2018-10-16T21:01:05.851Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p4qIz4aRRF4K5Vsakp5iEg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/hXOGHaGCtdA?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Aron Van de Pol</a> on <a href="https://unsplash.com/search/photos/well?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>So you’ve decided to start the journey of learning to code…. <br>Congratulations and join the club!<br>Just like you, I have recently started pursuing web development as my full-time career.</p><p>One of the first things I noticed as an aspiring programmer is: <br>The vast information at our disposal is overwhelming!</p><p>From articles to discussions about languages to start with.<br>Many even break it down to the order of frameworks to use and learn first.</p><h4>My favourite ones is <a href="https://medium.com/level-up-web/developer-roadmaps-all-in-one-place-75c0402db0e0">this web developer roadmap</a> by <a href="https://medium.com/u/d4eb92ea1991">Kamran Ahmed</a>.</h4><p><a href="http://github.com/kamranahmedse/developer-roadmap">kamranahmedse/developer-roadmap</a></p><p>Have you seen it? WOW, it’s a lot to take in, isn’t it?</p><h3>I wanted to have structured guidance.</h3><p>In order to help myself organise my learning, especially around coding best-practices, I started attending a full-time web-development bootcamp.</p><p>On day one the mentors told us that the best approach, and the approach that will be used in the bootcamp, is the 80–20 rule:</p><blockquote>20% of effort (or knowledge in our case)<br>will bring out 80% of the required result.</blockquote><p>But the other 80% that is not taught in class is oh sooooo interesting and tempting!<br>More and more I find myself in a situation where working on a simple problem or “kata” on “<a href="http://www.codewars.com/"><strong>codewars</strong></a><strong>”</strong> leads me down a bunch of rabbit holes of discovering new topics and methodologies.</p><h3>So I decided to treat each topic as a side project.</h3><p>I was introduced to Trello, that not only helped me managed my bootcamp projects, but all the rabbit holes I find myself looking into.</p><h4>The scenario would usually turn out like this:</h4><ol><li><strong>Every time I notice myself going too deep into researching</strong> a new topic I would stop myself and check if I already have enough understanding of the topic to solve the problem at hand. If I do…</li><li><strong>I’d create a card in Trello</strong>, so that I can return to the topic later, when I can dedicate some time to just learn the topic and understand how to apply it.</li><li><strong>I then fill in the checklist with the materials to read and practice tasks</strong> to do in order to understand the topic, while researching.<br>After all the best way to learn something is to practice it!</li><li><strong>The last item on the checklist is usually writing an article.<br></strong>Writing helps me organise my thoughts, structure what I learned and save the resources I used. It also will help future me in case I need to refresh my memory, as well as help anyone who might be interested in the same topics.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ed9Xf2oWqBgpNaZj6Q0fnw.png" /><figcaption>My Rabbit Tunnels</figcaption></figure><p><em>Got great ways to learn new languages, frameworks, methods and the likes?</em><strong><em>Please share in the comments!</em></strong></p><h3>EXTRAS: My thoughts on display…</h3><blockquote>Coming back to a webpage I created a while ago and realising that I can’t make heads or tails of the code I wrote. Hmmmm… There must be a better way to organise it. Oh look, SMACSS, BOE, OOCSS! Looks promising!</blockquote><blockquote>Doing a codewars kata for replacing characters in a string. There must be a better way than just going through each character, what does stack overflow say about it? What? RegEx? Are you saying I could have solved last 5 katas in just one line?</blockquote><blockquote>I keep hearing that Vim is a powerful text editor. Isn’t Vim that weird thing in the terminal that I couldnt’t figure out how to exit?</blockquote><blockquote>After researching class variables and how to use them in Ruby I came across the term code smell. What? How can code smell?</blockquote><h4>Disclaimers: if you haven’t gone down the “<a href="http://www.codewars.com/"><strong>codewars</strong></a>” rabbit hole yet, I highly recommend it.</h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1be1726e7fde" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>