<?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[Regex: Put a dot after every 10 words]]></title><description><![CDATA[<p dir="auto">hi, I need to put a dot after every 10 words. My regex is not so good:</p>
<p dir="auto">SEARCH: <code>(\w+){0,5}</code><br />
REPLACE BY: <code>\1.</code></p>
]]></description><link>https://community.notepad-plus-plus.org/topic/21885/regex-put-a-dot-after-every-10-words</link><generator>RSS for Node</generator><lastBuildDate>Wed, 17 Jun 2026 14:00:38 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/21885.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Sep 2021 21:24:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Regex: Put a dot after every 10 words on Thu, 24 Nov 2022 15:29:09 GMT]]></title><description><![CDATA[<p dir="auto">Hi, @neculai-i-fantanaru and <strong>All</strong>,</p>
<p dir="auto">I forgot to explain why the <strong>first</strong> provided regex was <strong><code>(?:([\w'’]+)\W+){9}(?1)\K</code></strong> and <strong>not</strong> the regex <strong><code>(?:([\w'’]+)\W+){9}\1\K</code></strong></p>
<hr />
<p dir="auto">Well, the <strong><code>\1</code></strong> <strong>right before</strong> <strong><code>\K</code></strong> would match the <strong>last</strong> occurrence of the <strong>group <code>1</code></strong>, that is the <strong>ninth</strong> word found with the regex <strong><code>[\w'’]+</code></strong> !</p>
<p dir="auto">So, the regex <strong><code>(?:([\w'’]+)\W+){9}\1</code></strong> would match strings like :</p>
<pre><code class="language-diff">111 222 333 444 555 666 777 888 999 999
</code></pre>
<p dir="auto">or</p>
<pre><code class="language-diff">000 111 222 333 444 555 666 777 888 888
</code></pre>
<p dir="auto">but <em>NOT</em> the string :</p>
<pre><code class="language-diff">000 111 222 333 444 555 666 777 888 999
</code></pre>
<hr />
<p dir="auto">On the contrary, the <strong><code>(?1)</code></strong> syntax, is a <strong>subroutine call</strong> to the <strong>group <code>1</code></strong> and is, fundamentally, <strong>identical</strong> to the regex <strong><code>[\w'’]+</code></strong> <strong>itself</strong>. So, the regex <strong><code>(?:([\w'’]+)\W+){9}(?1)</code></strong> would also match my <strong>third</strong> example too and <strong>any</strong> other word ;-))</p>
<p dir="auto">Best Regards</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70070</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70070</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 24 Nov 2022 15:29:09 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: Put a dot after every 10 words on Mon, 27 Sep 2021 16:55:42 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a> said in <a href="/post/70054">Regex: Put a dot after every 10 words</a>:</p>
<blockquote>
<p dir="auto">(?:([\w’’]+)\W+){9}(?1)\K</p>
</blockquote>
<p dir="auto">thank you <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/70067</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70067</guid><dc:creator><![CDATA[Neculai I. Fantanaru]]></dc:creator><pubDate>Mon, 27 Sep 2021 16:55:42 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: Put a dot after every 10 words on Thu, 24 Nov 2022 15:27:40 GMT]]></title><description><![CDATA[<p dir="auto">Hello, @neculai-i-fantanaru, <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a> and <strong>All</strong>,</p>
<p dir="auto">I <strong>agree</strong> with <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>’s comments and let you look for a solution by <strong>yourself</strong> ! But, apparently, you’ve reached a <strong>dead-end</strong> !</p>
<p dir="auto">You said :</p>
<blockquote>
<p dir="auto">hi, I need to put a dot after every 10 words</p>
</blockquote>
<p dir="auto">But you haven’t shown us <strong>which</strong> kind of text is concerned  :-(</p>
<p dir="auto">I suppose that your <strong>initial</strong> text does <strong>not</strong> contain any <strong>punctuation</strong> and is, mainly, a list of <strong>words</strong>, separated with <strong>space</strong> characters ?!</p>
<hr />
<p dir="auto">As an example, let’s take the <strong>first</strong> sentence of the <strong>preamble</strong> of the <strong><code>license.txt</code></strong> file</p>
<pre><code class="language-diff">The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.
</code></pre>
<p dir="auto"><em>AFTER</em> removing any <strong>punctuation</strong> sign, we get :</p>
<pre><code class="language-diff">The licenses for most software are designed to take away your freedom to share and change it By contrast the GNU General Public License is intended to guarantee your freedom to share and change free software to make sure the software is free for all its users This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it Some other Free Software Foundation software is covered by the GNU Library General Public License instead You can apply it to your programs too
</code></pre>
<p dir="auto">Note that, in this sentence, it remains the <strong>possessive</strong> structure <strong><code>Free Software Foundation's software</code></strong>. To my mind, the expression <strong><code>Foundation's</code></strong> should be considered as a <strong>single</strong> word, as well as other <strong>contracted</strong> English forms such as <strong><code>I'm</code></strong>, <strong><code>don't</code></strong>,…</p>
<p dir="auto">So, an appropriate <strong>regex</strong> S/R could be :</p>
<p dir="auto">SEARCH <strong><code>(?:([\w'’]+)\W+){9}(?1)\K</code></strong>    or    <strong><code>(?:[\w'’]+\W+){9}[\w'’]+\K</code></strong></p>
<p dir="auto">REPLACE <strong><code>.</code></strong></p>
<p dir="auto">And, after a <strong>single</strong> click on the <strong><code>Replace All</code></strong> button, this <em>OUTPUT</em> sentence becomes :</p>
<pre><code class="language-diff">The licenses for most software are designed to take. away your freedom to share and change it By contrast. the GNU General Public License is intended to guarantee your. freedom to share and change free software to make sure. the software is free for all its users This General. Public License applies to most of the Free Software Foundation's. software and to any other program whose authors commit to. using it Some other Free Software Foundation software is covered. by the GNU Library General Public License instead You can. apply it to your programs too
</code></pre>
<p dir="auto">However, note that this text is <strong>not</strong> consistent as a <strong>full stop</strong> is inserted <strong>every</strong> <strong><code>10</code></strong> words and does <strong>not</strong> respect, obviously, the English language !!</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70054</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70054</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Thu, 24 Nov 2022 15:27:40 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: Put a dot after every 10 words on Mon, 27 Sep 2021 05:01:40 GMT]]></title><description><![CDATA[<p dir="auto">can anyone help me? <a class="plugin-mentions-user plugin-mentions-a" href="/user/guy038" aria-label="Profile: guy038">@<bdi>guy038</bdi></a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/70051</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70051</guid><dc:creator><![CDATA[Neculai I. Fantanaru]]></dc:creator><pubDate>Mon, 27 Sep 2021 05:01:40 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: Put a dot after every 10 words on Sun, 26 Sep 2021 11:23:25 GMT]]></title><description><![CDATA[<p dir="auto">oh, yes. I mention 5 words, sorry, should be 10 words. But the regex should be the same (I will change the number)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70035</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70035</guid><dc:creator><![CDATA[Neculai I. Fantanaru]]></dc:creator><pubDate>Sun, 26 Sep 2021 11:23:25 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: Put a dot after every 10 words on Sun, 26 Sep 2021 11:14:07 GMT]]></title><description><![CDATA[<p dir="auto">@Neculai-I-Fantanaru</p>
<p dir="auto">Sorry, it’s just that your initial regex looked very suspicious, because you mentioned 10 but then nothing even close to 10 appeared in your regex.</p>
<p dir="auto">So <code>\w</code> does NOT mean to match a “word”, it means match a “word character”.</p>
<p dir="auto">For example, there are three word characters in the first word of this:</p>
<p dir="auto"><code>abc defg hijkl</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/70034</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70034</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sun, 26 Sep 2021 11:14:07 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: Put a dot after every 10 words on Sun, 26 Sep 2021 06:48:45 GMT]]></title><description><![CDATA[<p dir="auto">ok, I have another solution, will put a dot at every 5 words. But seems to work only for the first line, not for all lines:</p>
<p dir="auto">SEARCH: <code>(\w+){10}\K</code><br />
REPLACE BY: <code>\1.</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/70031</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70031</guid><dc:creator><![CDATA[Neculai I. Fantanaru]]></dc:creator><pubDate>Sun, 26 Sep 2021 06:48:45 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: Put a dot after every 10 words on Sun, 26 Sep 2021 06:40:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a> good day, sir. My regex is not just thrown out there, in order to get some help. It is a solution, a step forward. I know is not good, but I don’t know any other solution…</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70030</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70030</guid><dc:creator><![CDATA[Neculai I. Fantanaru]]></dc:creator><pubDate>Sun, 26 Sep 2021 06:40:46 GMT</pubDate></item><item><title><![CDATA[Reply to Regex: Put a dot after every 10 words on Sat, 25 Sep 2021 23:05:42 GMT]]></title><description><![CDATA[<p dir="auto">@Neculai-I-Fantanaru</p>
<p dir="auto">Now THAT looks like a regex just thrown out there, in order to get some help.<br />
Can you please explain how that regex is supposed to work?<br />
If you do that, perhaps you’ll see what’s wrong with it.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/70024</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/70024</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 25 Sep 2021 23:05:42 GMT</pubDate></item></channel></rss>