<?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"><channel><title><![CDATA[Surprising regular expression !]]></title><description><![CDATA[<p dir="auto">Hi, *<em>All</em>,</p>
<p dir="auto">Here is a little exercise for a <strong>Sunday</strong> !</p>
<hr />
<ul>
<li>
<p dir="auto">Start <strong>N++</strong> and open a new file ( <strong><code>Ctrl + N</code></strong> )</p>
</li>
<li>
<p dir="auto">Write <strong><code>2,047</code></strong> consecutive <strong>empty</strong> lines</p>
</li>
<li>
<p dir="auto">Save your file</p>
</li>
<li>
<p dir="auto">Move <strong>back</strong> to its very <strong>beginning</strong> ( Ctrl + Home )</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Edit &gt; Column Editor..</code></strong>  option or use the <strong><code>Alt + C </code></strong> shortcut</p>
</li>
<li>
<p dir="auto">Enter the values <strong><code>0 , 1 , 1</code></strong> to define the <strong>sequence</strong></p>
</li>
<li>
<p dir="auto">Select the leading <strong><code>Zeros</code></strong> option and the <strong><code>Bin</code></strong> format</p>
</li>
</ul>
<p dir="auto">=&gt; You should get a list of <strong>binary</strong> numbers between <strong><code>0</code></strong> and <strong><code>111 1111 1111</code></strong></p>
<ul>
<li>
<p dir="auto">Now, open the <strong>Mark</strong> dialog ( <strong><code>Ctrl + M</code></strong> )</p>
<ul>
<li>
<p dir="auto"><strong>Uncheck</strong> all <strong>box</strong> options</p>
</li>
<li>
<p dir="auto">Enter the regex  <strong><code>^(0|(1(01*0)*1))*$</code></strong> in the <strong>Find what</strong> field</p>
</li>
<li>
<p dir="auto">Check the <strong><code>Bookmark line</code></strong> and <strong><code>Wrap around</code></strong> options</p>
</li>
<li>
<p dir="auto">Select the <strong><code>Regular expression</code></strong> mode</p>
</li>
<li>
<p dir="auto">Click on the <strong><code>Mark All</code></strong> button</p>
</li>
</ul>
</li>
<li>
<p dir="auto">Close the <strong>Mark</strong> dialog or hit the <strong><code>ESC</code></strong> key</p>
</li>
</ul>
<hr />
<p dir="auto">Now, in your opinion, what do <strong>all</strong> these <strong>marked</strong> lines represent ? …</p>
<p dir="auto">After a while, it should be enough <strong>easy</strong> to detect that any <strong>marked</strong> line is a number <strong><code>multiple of 3</code></strong>  !</p>
<p dir="auto">Therefore, the main takeaway from this text, is that <strong>regexes</strong> can simulate <strong>mathematical</strong> formulas !</p>
<hr />
<p dir="auto">Of course, I did <strong>not</strong> come up with that regex on my <strong>own</strong>, but by referring to the <strong>last</strong> example in this <strong>Wikipedia</strong> article :</p>
<p dir="auto"><a href="https://en.wikipedia.org/wiki/Regular_expression#Formal_definition" rel="nofollow ugc">https://en.wikipedia.org/wiki/Regular_expression#Formal_definition</a></p>
<p dir="auto">Now, I suppose that other regexes could <strong>simulate</strong> other multiples or formulas, as long, as we simply use the <strong>binary</strong> format but I have <strong>not</strong> tested anything yet !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/27511/surprising-regular-expression</link><generator>RSS for Node</generator><lastBuildDate>Sun, 26 Apr 2026 17:28:31 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/27511.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 26 Apr 2026 12:27:21 GMT</pubDate><ttl>60</ttl></channel></rss>