<?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[Insert a string after each number of words with conditions]]></title><description><![CDATA[<p dir="auto">What I wan to accomplish is a little bit complicated.<br />
I want to insert the string [NEWLINE] after every 44 characters length including spaces. But with respect the the string cannot be in the middle of a word, and in that case the string should go back to the space before the that word.</p>
<p dir="auto"><strong>Example #one</strong><br />
<strong>Straight forward</strong></p>
<p dir="auto"><em>Original text</em><br />
As your advisor I am qualified to assist you in all matters related to rule civilization. If you don’t require my services dismiss me to attend to other matters.</p>
<p dir="auto"><em>Result</em><br />
As your advisor I am qualified to assist you[NEWLINE]in all matters related to rule civilization.[NEWLINE]**If you don’t require my services dismiss me[NEWLINE]to attend to other matters.</p>
<p dir="auto">As your advisor I am qualified to assist you= 44 Characters<br />
in matters related to ruling civilization.= 44 Characters<br />
If you don’t require my services dismiss me= 44 Characters<br />
to attend to other matters.= 28 Characters</p>
<p dir="auto"><strong>Example #two</strong></p>
<p dir="auto"><em>Original text</em><br />
Greetings My Liege! As your personal advisor, I am qualified to assist you in all matters related to ruling our civilization. I am at your service.</p>
<p dir="auto"><em>Wrong Unwated Result</em><br />
Greetings My Liege! As your personal advisor[NEWLINE], I am qualified to assist you in all matter[NEWLINE]s related to ruling our civilization. I am a[NEWLINE]t your service.</p>
<p dir="auto">Greetings My Liege! As your personal advisor= 44 Characters<br />
, I am qualified to assist you in all matter= 44 Characters<br />
s related to ruling our civilization. I am a= 44 Characters<br />
t your service.= 15 Characters</p>
<p dir="auto"><em>Seeked Result</em><br />
Greetings My Liege! As your personal[NEWLINE]advisor, I am qualified to assist you in all[NEWLINE]matters related to ruling our civilization. [NEWLINE] I am at your service.</p>
<p dir="auto">Greetings My Liege! As your personal= 36 Characters<br />
advisor, I am qualified to assist you in all= 44 Characters<br />
matters related to ruling our civilization. = 44 Characters<br />
I am at your service.= 22 Characters</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/13686/insert-a-string-after-each-number-of-words-with-conditions</link><generator>RSS for Node</generator><lastBuildDate>Fri, 15 May 2026 22:48:53 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/13686.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 20 Apr 2017 13:28:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Tue, 03 Apr 2018 04:03:20 GMT]]></title><description><![CDATA[<p dir="auto">I modified the original Search regex, as it catches some Unicode characters with will break the line in a middle of a word. So in the modified regex I replace \W with \x20 (space character)… so far no word breaking issues<br />
Here is the modified one<br />
(?-s).{1,44}(?=\x20)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/31400</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/31400</guid><dc:creator><![CDATA[abuali huma]]></dc:creator><pubDate>Tue, 03 Apr 2018 04:03:20 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Mon, 19 Jun 2017 02:27:07 GMT]]></title><description><![CDATA[<p dir="auto">I found out the removing the   <code>\x20 </code> does what I described… Thanks again</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24984</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24984</guid><dc:creator><![CDATA[abuali huma]]></dc:creator><pubDate>Mon, 19 Jun 2017 02:27:07 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Sun, 18 Jun 2017 17:14:28 GMT]]></title><description><![CDATA[<p dir="auto">Thanks very much!<br />
But just to be clear, in the first regex</p>
<p dir="auto">SEARCH (?-s)\x20?[NEWLINE]\x20?|(?&lt;=.)$</p>
<p dir="auto">REPLACE #</p>
<p dir="auto">Removing the value ** <code>\x20 </code>** will result this<br />
SEARCH (?-s)?[NEWLINE]?|(?&lt;=.)$</p>
<p dir="auto">Which will result capturing the space  “if available” before and after [NEWLINE] string in first and last group?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24978</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24978</guid><dc:creator><![CDATA[abuali huma]]></dc:creator><pubDate>Sun, 18 Jun 2017 17:14:28 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Sun, 18 Jun 2017 16:32:59 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/abuali-huma" aria-label="Profile: abuali-huma">@<bdi>abuali-huma</bdi></a>,</p>
<p dir="auto">I found a <strong>general</strong> method, which uses <strong>three consecutive</strong> S/R. We’ll need <strong>two dummy</strong> characters, <strong>NOT</strong> used in the <strong>current</strong> file. I, personally, chose the <strong><code>#</code></strong> and <strong><code>@</code></strong> characters, but any <strong>other</strong> may be used !</p>
<ul>
<li>
<p dir="auto">The <strong>first</strong> S/R :</p>
<ul>
<li>
<p dir="auto">Changes any string <strong>[NEWLINE]</strong>, possibly <strong>preceded</strong> and/or <strong>followed</strong> with a <strong>space</strong> character, by the <strong>dummy</strong> character <strong><code>#</code></strong></p>
</li>
<li>
<p dir="auto">Adds, also, a <strong><code>#</code></strong> character at the <strong>end</strong> of any <strong>non-blank</strong> line</p>
</li>
</ul>
</li>
<li>
<p dir="auto">The <strong>second</strong> S/R is the <strong>main</strong> S/R, which <strong>rewrites</strong> the different parts, between the <strong><code>#</code></strong> character, in <strong>reverse</strong> order.</p>
<ul>
<li>
<p dir="auto">Note that this <strong>S/R</strong> will have to be performed <strong>as many times</strong>, till the message <strong>Replace All: 0 occurrences were replaced</strong> occurs, in the <strong>Replace</strong> dialog</p>
</li>
<li>
<p dir="auto">The general idea, about this S/R, is to <strong>switch</strong> the <strong>beginning</strong> and <strong>ending</strong> parts of the found text, adding a <strong><code>@</code></strong> character, at the <strong>end</strong> of the <strong>exchanged</strong> parts, in order that the <strong>next</strong> run of this S/R, will <strong>avoid</strong> these <strong>moved</strong> parts of text ! Hence, the <strong>decreasing</strong> number of occurrences found, till <strong>zero</strong> :-))</p>
</li>
</ul>
</li>
<li>
<p dir="auto">The <strong>Third</strong> S/R :</p>
<ul>
<li>
<p dir="auto">Changes the <strong><code>#</code></strong> character, possibly <strong>preceded</strong> by a <strong><code>@</code></strong> character, <strong>inside</strong> text, by the string <strong>[NEXLINE]</strong>, preceded and followed with a <strong>space</strong> character</p>
</li>
<li>
<p dir="auto">Deletes the <strong><code>#</code></strong> character, possibly <strong>preceded</strong> by a <strong><code>@</code></strong> character, when located at the <strong>end</strong> of the lines</p>
</li>
</ul>
</li>
</ul>
<p dir="auto">All these S/R will use the <strong>Regular expression</strong> search mode, the <strong>Wrap around</strong> option and the <strong>Replace All</strong> button, of the <strong>Replace</strong> dialog</p>
<p dir="auto">So, let’s start with the <strong>original</strong> text, below :</p>
<pre><code class="language-diff">One [NEWLINE] two [NEWLINE] three [NEWLINE] four [NEWLINE] five [NEWLINE] six [NEWLINE] seven [NEWLINE] eight [NEWLINE] nine [NEWLINE] ten [NEWLINE] eleven [NEWLINE] twelve
One [NEWLINE] two [NEWLINE] three [NEWLINE] four [NEWLINE] five [NEWLINE] six [NEWLINE] seven [NEWLINE] eight [NEWLINE] nine [NEWLINE] ten [NEWLINE] eleven
One [NEWLINE] two [NEWLINE] three [NEWLINE] four [NEWLINE] five [NEWLINE] six [NEWLINE] seven [NEWLINE] eight [NEWLINE] nine [NEWLINE] ten
Other text NOT concerned
by this Search Replacement
One [NEWLINE] two [NEWLINE] three [NEWLINE] four [NEWLINE] five [NEWLINE] six [NEWLINE] seven [NEWLINE] eight [NEWLINE] nine
One [NEWLINE] two [NEWLINE] three [NEWLINE] four [NEWLINE] five [NEWLINE] six [NEWLINE] seven [NEWLINE] eight
One [NEWLINE] two [NEWLINE] three [NEWLINE] four [NEWLINE] five [NEWLINE] six [NEWLINE] seven
Bla bla blah
Bla bla blah
Bla bla blah
One [NEWLINE] two [NEWLINE] three [NEWLINE] four [NEWLINE] five [NEWLINE] six
One [NEWLINE] two [NEWLINE] three [NEWLINE] four [NEWLINE] five
One [NEWLINE] two [NEWLINE] three [NEWLINE] four
Dummy text
inserted, in between !
One [NEWLINE] two [NEWLINE] three
One [NEWLINE] two
One
I want [NEWLINE] this [NEWLINE] to be  [NEWLINE] last
</code></pre>
<hr />
<p dir="auto">After running the following S/R , <strong>once</strong> :</p>
<p dir="auto">SEARCH <strong><code>(?-s)\x20?\[NEWLINE\]\x20?|(?&lt;=.)$</code></strong></p>
<p dir="auto">REPLACE <strong><code>#</code></strong></p>
<p dir="auto">You should get the text, below :</p>
<pre><code class="language-diff">One#two#three#four#five#six#seven#eight#nine#ten#eleven#twelve#
One#two#three#four#five#six#seven#eight#nine#ten#eleven#
One#two#three#four#five#six#seven#eight#nine#ten#
Other text NOT concerned#
by this Search Replacement#
One#two#three#four#five#six#seven#eight#nine#
One#two#three#four#five#six#seven#eight#
One#two#three#four#five#six#seven#
Bla bla blah#
Bla bla blah#
Bla bla blah#
One#two#three#four#five#six#
One#two#three#four#five#
One#two#three#four#
Dummy text#
inserted, in between !#
One#two#three#
One#two#
One#
I want#this#to be #last#
</code></pre>
<hr />
<p dir="auto">After running the following S/R, <strong><code>SEVEN</code></strong> times, <strong>one</strong> after <strong>another</strong> :</p>
<p dir="auto">SEARCH <strong><code>(?-s)([^@#\r\n]+?)#(.+#)?([^@#\r\n]+)#</code></strong></p>
<p dir="auto">REPLACE <strong><code>\3@#\2\1@#</code></strong></p>
<p dir="auto">The <strong>modified</strong> text is, now :</p>
<pre><code class="language-diff">twelve@#eleven@#ten@#nine@#eight@#seven@#six@#five@#four@#three@#two@#One@#
eleven@#ten@#nine@#eight@#seven@#six#five@#four@#three@#two@#One@#
ten@#nine@#eight@#seven@#six@#five@#four@#three@#two@#One@#
Other text NOT concerned#
by this Search Replacement#
nine@#eight@#seven@#six@#five#four@#three@#two@#One@#
eight@#seven@#six@#five@#four@#three@#two@#One@#
seven@#six@#five@#four#three@#two@#One@#
Bla bla blah#
Bla bla blah#
Bla bla blah#
six@#five@#four@#three@#two@#One@#
five@#four@#three#two@#One@#
four@#three@#two@#One@#
Dummy text#
inserted, in between !#
three@#two#One@#
two@#One@#
One#
last@#to be @#this@#I want@#
</code></pre>
<p dir="auto"><strong>Seven consecutive</strong> runs of that regex S/R are <strong>required</strong>, to get the <strong>sought</strong> text :</p>
<ul>
<li>Run <strong>1</strong> : <strong>12</strong> occurrences replaced</li>
<li>Run <strong>2</strong> : <strong>10</strong> occurrences replaced</li>
<li>Run <strong>3</strong> : <strong>7</strong> occurrences replaced</li>
<li>Run <strong>4</strong> : <strong>5</strong> occurrences replaced</li>
<li>Run <strong>5</strong> : <strong>3</strong> occurrences replaced</li>
<li>Run <strong>6</strong> : <strong>1</strong> occurrences replaced</li>
<li>Run <strong>7</strong> : <strong>0</strong> occurrences replaced</li>
</ul>
<p dir="auto"><strong>Note</strong> : After <strong>each</strong> run, you may hit the <strong>Find Next</strong> button, before hitting the <strong>Replace All</strong> button, to guess the <strong>general</strong> process !</p>
<p dir="auto">The part <strong><code>[^@#\r\n]</code></strong>, in the <strong>searched</strong> regex, represents any <strong>single</strong> character, <strong>different</strong> from <strong><code>@</code></strong>, <strong><code>#</code></strong>, <strong><code>\n</code></strong> and <strong><code>\r</code></strong></p>
<hr />
<p dir="auto">Then, after running the <strong>last</strong> S/R, <strong>once</strong> :</p>
<p dir="auto">SEARCH <strong><code>(?-s)(@?#)(?=.)|@?#</code></strong></p>
<p dir="auto">REPLACE <strong><code>?1\x20[NEWLINE]\x20</code></strong></p>
<p dir="auto">We obtain our <strong>final</strong> text :</p>
<pre><code class="language-diff">twelve [NEWLINE] eleven [NEWLINE] ten [NEWLINE] nine [NEWLINE] eight [NEWLINE] seven [NEWLINE] six [NEWLINE] five [NEWLINE] four [NEWLINE] three [NEWLINE] two [NEWLINE] One
eleven [NEWLINE] ten [NEWLINE] nine [NEWLINE] eight [NEWLINE] seven [NEWLINE] six [NEWLINE] five [NEWLINE] four [NEWLINE] three [NEWLINE] two [NEWLINE] One
ten [NEWLINE] nine [NEWLINE] eight [NEWLINE] seven [NEWLINE] six [NEWLINE] five [NEWLINE] four [NEWLINE] three [NEWLINE] two [NEWLINE] One
Other text NOT concerned
by this Search Replacement
nine [NEWLINE] eight [NEWLINE] seven [NEWLINE] six [NEWLINE] five [NEWLINE] four [NEWLINE] three [NEWLINE] two [NEWLINE] One
eight [NEWLINE] seven [NEWLINE] six [NEWLINE] five [NEWLINE] four [NEWLINE] three [NEWLINE] two [NEWLINE] One
seven [NEWLINE] six [NEWLINE] five [NEWLINE] four [NEWLINE] three [NEWLINE] two [NEWLINE] One
Bla bla blah
Bla bla blah
Bla bla blah
six [NEWLINE] five [NEWLINE] four [NEWLINE] three [NEWLINE] two [NEWLINE] One
five [NEWLINE] four [NEWLINE] three [NEWLINE] two [NEWLINE] One
four [NEWLINE] three [NEWLINE] two [NEWLINE] One
Dummy text
inserted, in between !
three [NEWLINE] two [NEWLINE] One
two [NEWLINE] One
One
last [NEWLINE] to be  [NEWLINE] this [NEWLINE] I want
</code></pre>
<p dir="auto">The <strong>search</strong>  part looks for the regex <strong><code>@?#</code></strong>, either, <strong>inside</strong> the lines ( case <strong>group 1 defined</strong> ) or at <strong>end</strong> of lines ( case <strong>NO group 1</strong> )</p>
<p dir="auto">The <strong>replacement</strong> part means that, IF <strong>group 1 exists</strong>, the <strong>searched</strong> text is replaced by the string <strong>[NEWLINE]</strong>, surrounded by <strong>space</strong> characters, ELSE <strong>NO</strong> replacement occurs</p>
<p dir="auto">Et voilà !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/24977</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24977</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 18 Jun 2017 16:32:59 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Sun, 18 Jun 2017 10:02:01 GMT]]></title><description><![CDATA[<ul>
<li>Sorry for pumping up old thread, but my issue is related to this one.</li>
</ul>
<p dir="auto">Cutting to the thread…<br />
Look at Result#2 with desired arrangement</p>
<pre><code class="language-diff">-Example# 2
Greetings My Liege! As your personal advisor [NEWLINE] , I am qualified to assist you in all[NEWLINE] matters related to ruling our civilization.[NEWLINE] I am at your service.

--------
+Seeked arrangement
I am at your service. [NEWLINE] matters related to ruling our civilization.[NEWLINE], I am qualified to assist you in all[NEWLINE]Greetings My Liege! As your personal advisor
</code></pre>
<p dir="auto">I asked before for a way to rearrange the groups between <strong>[NEWLINE]</strong> to be backward… Now I’m asking for the same but in more automated way…</p>
<p dir="auto">Because not all lines have the same amount of Groups, I want to arrange all the lines that contains Groups between <strong>[NEWLINE]</strong> to be backward arrangement.</p>
<pre><code class="language-diff">-Example#3 Contains SIX groups
One [NEWLINE] two [NEWLINE] three [NEWLINE] four [NEWLINE] five [NEWLINE] six

-------
+Seeked arrangement
 six[NEWLINE] five [NEWLINE] four [NEWLINE] three [NEWLINE] two [NEWLINE]One
</code></pre>
<p dir="auto">While using the same regex or python script</p>
<pre><code class="language-diff">-Example#4 Contains 4 groups 
I want [NEWLINE] this [NEWLINE] to be  [NEWLINE] last

------
+Seeked arrangement
 last[NEWLINE] to be [NEWLINE] this [NEWLINE]I want 
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/24972</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/24972</guid><dc:creator><![CDATA[abuali huma]]></dc:creator><pubDate>Sun, 18 Jun 2017 10:02:01 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Tue, 25 Apr 2017 09:41:58 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="/user/hu-ma" aria-label="Profile: hu-ma">@<bdi>hu-ma</bdi></a> and <strong>All</strong></p>
<p dir="auto">To complete the <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: scott-sumner">@<bdi>scott-sumner</bdi></a> post, about the <strong>two</strong> syntaxes of the <strong>searched</strong> groups, in <strong>replacement</strong> :</p>
<ul>
<li>
<p dir="auto"><strong><code>\N</code></strong>, with <strong>0 &lt; N &lt; 10</strong></p>
</li>
<li>
<p dir="auto"><strong><code>$N</code></strong>, with <strong>0 &lt;= N &lt; 2,147,483,648</strong></p>
</li>
</ul>
<p dir="auto">There is the other <strong>practical</strong> syntax, below :</p>
<ul>
<li><strong><code>${N}</code></strong>, with <strong>0 &lt;= N &lt; 2,147,483,648</strong></li>
</ul>
<hr />
<p dir="auto">Indeed, let’s imagine the <strong>original</strong> text:</p>
<pre><code class="language-diff">abcd
1234
WXYZ
</code></pre>
<p dir="auto">and the <strong>first</strong> S/R :</p>
<p dir="auto">SEARCH <strong><code>^.(..).</code></strong></p>
<p dir="auto">REPLACE <strong><code>$100|</code></strong></p>
<p dir="auto">You obtain the simple text :</p>
<pre><code class="language-diff">|
|
|
</code></pre>
<p dir="auto">Why ?! Just because, in <strong>replacement</strong>, the regex engine is looking for the group <strong><code>$100</code></strong>, which, obviously, does <strong>not</strong> exist ! So, the regex engine rewrites a <strong>zero-length</strong> string, for the <strong>non-existent</strong> group <strong>100</strong>, followed by the <strong>literal</strong> character <strong><code>|</code></strong> !</p>
<p dir="auto">Now, compare, with the <strong>second</strong> S/R, below :</p>
<p dir="auto">SEARCH <strong><code>^.(..).</code></strong></p>
<p dir="auto">REPLACE <strong><code>${1}00|</code></strong></p>
<p dir="auto">This time, you, <strong>correctly</strong>, get the text, below :</p>
<pre><code class="language-diff">bc00|
2300|
XY00|
</code></pre>
<p dir="auto">=&gt; All the <strong>changed</strong> lines begin by the <strong>second</strong> and <strong>third</strong> characters of the <strong>original</strong> lines of text ( <strong><code>$1</code></strong> ), and are, simply, followed by the string <strong><code>00|</code></strong></p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23876</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23876</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Tue, 25 Apr 2017 09:41:58 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Tue, 25 Apr 2017 00:14:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: Scott-Sumner">@<bdi>Scott-Sumner</bdi></a><br />
Thanks for the info!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23873</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23873</guid><dc:creator><![CDATA[hu ma]]></dc:creator><pubDate>Tue, 25 Apr 2017 00:14:00 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Mon, 24 Apr 2017 18:42:42 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <strong>Alan</strong>,</p>
<p dir="auto">Yes, you’re right about it : I should have created a <strong>new</strong> post with the <strong>corrections</strong>, for a better <strong>history</strong>  ! It’s just that my <strong>updated</strong> post was, still, quite <strong>long</strong> and I thought it would be more <strong>clear</strong> to, simply, change my <strong>initial</strong> post. But, I do understand your point of view !</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23864</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23864</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 24 Apr 2017 18:42:42 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Mon, 24 Apr 2017 18:08:19 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></p>
<p dir="auto">And it is great that you have Admin rights here and can edit old posts, but I’m neutral on this.  I think that old posts should not be edited and clarifying posts should just be added on.  It is difficult to follow sometimes when history is CHANGED rather than simply CORRECTED/CLARIFIED later.  :-D</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23862</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23862</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 24 Apr 2017 18:08:19 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Mon, 24 Apr 2017 18:04:20 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></p>
<p dir="auto">Yes, in playing around with your original regex, I didn’t worry about the resulting space at the end of the line, as I have my “save” shortcut mapped to “trim trailing spaces” + “save”.  The ONLY way files should be saved (for me!).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23861</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23861</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 24 Apr 2017 18:04:20 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Mon, 24 Apr 2017 17:58:57 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/abuali-huma" aria-label="Profile: abuali-huma">@<bdi>abuali-huma</bdi></a>, <a class="plugin-mentions-user plugin-mentions-a" href="/user/scott-sumner" aria-label="Profile: scott-sumner">@<bdi>scott-sumner</bdi></a> and <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: alan-kilborn">@<bdi>alan-kilborn</bdi></a>,</p>
<p dir="auto"><strong>Alan</strong>, looking again to my <strong>previous</strong> post, you’re <strong>absolutely right</strong> about it. Can’t understand why I thought that the <strong>length</strong> of words was so important ! I should have been excessively <strong>tired</strong>, two days ago ;-))</p>
<p dir="auto">So , I’ve just completely <strong>updated</strong> my previous post, mentioning your <strong>contribution</strong> to that <strong>nicer</strong> regex. Thanks for that !</p>
<hr />
<p dir="auto">As for your <strong>own</strong> S/R, below :</p>
<p dir="auto">SEARCH <strong><code>(?-s)(.{1,43})\W</code></strong></p>
<p dir="auto">REPLACE <strong><code>$1\r\n</code></strong></p>
<p dir="auto">It just differs from my <strong>last</strong> S/R, of my previous post, as it does <strong>not</strong> take, in account, the final <strong>NON-word</strong> character, at position <strong>44</strong>, in the <strong>replacement</strong> part !</p>
<p dir="auto">Therefore, starting, again, from this part of the <strong>license.txt</strong> file, below :</p>
<pre><code class="language-diff">5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
</code></pre>
<p dir="auto">It would give the <strong>same</strong> text, <strong>without</strong> the <strong>space</strong> character, at the <strong>end</strong> of all the lines generated :</p>
<pre><code class="language-diff">5. You are not required to accept this
License, since you have not signed it.
However, nothing else grants you permission
to modify or distribute the Program or its
derivative works. These actions are
prohibited by law if you do not accept this
License. Therefore, by modifying or
distributing the Program (or any work based
on the Program), you indicate your
acceptance of this License to do so, and
all its terms and conditions for copying,
distributing or modifying the Program or
works based on it.
</code></pre>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23858</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23858</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Mon, 24 Apr 2017 17:58:57 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Mon, 24 Apr 2017 13:18:18 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></p>
<p dir="auto">I was playing around with this idea and I’m not sure I see the importance of introducing the complication of the “longest word in English” stuff.  For example, if I experiment with a variant of the regex that ignores this, I still get nice results:</p>
<p dir="auto">Find:  <code>(?-s)(.{1,43})\W</code><br />
Replace:  <code>$1\r\n</code></p>
<p dir="auto">…gives me nice text wrapping after the desired amount of columns.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23841</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23841</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 24 Apr 2017 13:18:18 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Mon, 24 Apr 2017 12:44:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/hu-ma" aria-label="Profile: hu-ma">@<bdi>hu-ma</bdi></a> said:</p>
<blockquote>
<p dir="auto">but I know this method can only work up to 9 captured groups</p>
</blockquote>
<p dir="auto">If you use the <code>\number</code> syntax, your statement is true.<br />
If you switch to the <code>$number</code> syntax, you can go higher than 9.</p>
<p dir="auto">For example, if you search for this regex:  <code>(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)</code><br />
And replace it with <code>$10</code><br />
On this text:  <code>abcdefghijklmnopqrstuvwxyz</code><br />
You will obtain:  <code>jopqrstuvwxyz</code></p>
<p dir="auto">Contrast with this example:<br />
search for this regex:  <code>(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)(l)(m)(n)</code><br />
And replace it with <code>\10</code><br />
On this text:  <code>abcdefghijklmnopqrstuvwxyz</code><br />
You will obtain:  <code>a0opqrstuvwxyz</code></p>
]]></description><link>https://community.notepad-plus-plus.org/post/23834</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23834</guid><dc:creator><![CDATA[Scott Sumner]]></dc:creator><pubDate>Mon, 24 Apr 2017 12:44:17 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Mon, 24 Apr 2017 01:55:30 GMT]]></title><description><![CDATA[<p dir="auto">Ummm…<br />
Back again, there is one more thing I need to do.<br />
Continuing with example#2 result which was</p>
<p dir="auto">Greetings My Liege! As your personal advisor[NEWLINE], I am qualified to assist you in all[NEWLINE] matters related to ruling our civilization.[NEWLINE] I am at your service.</p>
<p dir="auto"><em><strong>Seeked arrangement</strong></em><br />
I am at your service. [NEWLINE] matters related to ruling our civilization.[NEWLINE], I am qualified to assist you in all[NEWLINE]Greetings My Liege! As your personal advisor</p>
<p dir="auto">To put an understanding to it, I want to capture the text before, between, and after the string [NEWLINE] and change their order from \1\2\3\4 to \4\3\2\1.<br />
I can achieve this by first replacing the string [NEWLINE] to say ✓✓✓, then capture them by this regex<br />
search: (.+[\x{0000}-\x{9faf}])✓✓✓(.+[\x{0000}\x{9faf}])✓✓✓(.+[\x{0000}\x{9faf}])✓✓✓(.+[\x{0000}\x{9faf}])<br />
Replace : \4[NEWLINE]\3[NEWLINE]\2[NEWLINE]\1</p>
<p dir="auto">That can be happened, but I know this method can only work up to 9 captured groups, and I had some of them excceding 9 groups.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23813</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23813</guid><dc:creator><![CDATA[hu ma]]></dc:creator><pubDate>Mon, 24 Apr 2017 01:55:30 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Sun, 23 Apr 2017 10:27:35 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="/user/abuali-huma" aria-label="Profile: abuali-huma">@<bdi>abuali-huma</bdi></a>,</p>
<p dir="auto">Oh ! Sorry. I, initially, thought that you wrote the string <strong>[NEW LINE]</strong>, as a notation for a <strong>Line Break</strong> ! But, you <strong>did</strong> mean the <strong>litteral</strong> string <strong>[NEW LINE]</strong> ;-))</p>
<p dir="auto">Cheers,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23777</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23777</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 23 Apr 2017 10:27:35 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Sun, 23 Apr 2017 10:16:50 GMT]]></title><description><![CDATA[<p dir="auto">It works like charm.<br />
Just had to edit the regex to</p>
<p dir="auto">SEARCH (?-s).{16,44}(?=\W) – unchanged</p>
<p dir="auto">REPLACE $0[NEWLINE]</p>
<p dir="auto">So the example#2 output is<br />
<strong>Greetings My Liege! As your personal advisor</strong>[NEWLINE]<strong>, I am qualified to assist you in all</strong>[NEWLINE] <strong>matters related to ruling our civilization.</strong>[NEWLINE] <strong>I am at your service.</strong></p>
<p dir="auto">in order <strong>44</strong>[NEWLINE]<strong>37</strong>[NEWLINE]<strong>43</strong>[NEWLINE]<strong>22</strong></p>
]]></description><link>https://community.notepad-plus-plus.org/post/23776</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23776</guid><dc:creator><![CDATA[abuali huma]]></dc:creator><pubDate>Sun, 23 Apr 2017 10:16:50 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Sat, 22 Apr 2017 22:31:18 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:</p>
<blockquote>
<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/abuali-huma" aria-label="Profile: abuali-huma">@<bdi>abuali-huma</bdi></a>,</p>
<p dir="auto">I think that you could obtain what you want, by using a S/R, with <strong>regular</strong> expressions, but not exactly with the <strong>same template</strong> that you proposed !</p>
<p dir="auto">Before giving you the simple <strong>search</strong> and <strong>replacement</strong> regexes, needed, and the explanation of the <strong>slight</strong> differences with your seeked results, that produces this <strong>S/R</strong>, I would like to recapitulate your <strong>two</strong> examples, as I did <strong>not</strong> find, exactly, the same results as you ;-))</p>
<p dir="auto"><strong>IMPORTANT</strong> :</p>
<p dir="auto">Throughout all this post, I simply replaced the <strong>leading</strong> and <strong>trailing</strong> spaces, of the <strong>final</strong> lines of text, by the <strong>Double Low Line</strong> Unicode character <strong><code>‗</code></strong> ( <strong><code>\x{2017}</code></strong> ). It’s more readable and rigorous, isn’t it ?</p>
<pre><code class="language-c"># Original text 1

As your advisor I am qualified to assist you in all matters related to rule civilization. If you don’t require my services dismiss me to attend to other matters.

# Correct Result 1 :

As your advisor I am qualified to assist you‗       45
in all matters related to rule civilization.        44
‗If you don’t require my services dismiss me        44
‗to attend to other matters.                        28

------------------------------------------------------------------------

# Original text 2

Greetings My Liege! As your personal advisor, I am qualified to assist you in all matters related to ruling our civilization. I am at your service.

# Unwanted Result 2 :

Greetings My Liege! As your personal advisor        44
, I am qualified to assist you in all matter        44
s related to ruling our civilization. I am a        44
t your service.                                     15

# Wanted Result 2 :

Greetings My Liege! As your personal‗               37
advisor, I am qualified to assist you in all        44
‗matters related to ruling our civilization.        44
‗I am at your service.                              22
</code></pre>
<p dir="auto">To my mind, compared to your post, I think that :</p>
<ul>
<li>
<p dir="auto">The <strong>first</strong> block of the <strong>Correct Result 1</strong> is <strong>45</strong> characters long ( not 44 ), due to the <strong>final space</strong> character</p>
</li>
<li>
<p dir="auto">The <strong>first</strong> block of the <strong>Wanted Result 2</strong> is <strong>37</strong> character long ( not 36 ), for the same reason !</p>
</li>
</ul>
<hr />
<p dir="auto">Now, I think that the behaviour, about the <strong>slicing</strong> that you seek for, <strong>cannot</strong> be easily achieved with <strong>regular</strong> expressions, as the insertion of the <strong>End of Line</strong> character(s), inside text, would depend on the character <strong>right after</strong> the end of the <strong>next</strong> block of <strong>44</strong> characters ! I did try to find a suitable regex, without success, unfortunately :-((</p>
<p dir="auto">But I’ve got an other solution which works out the <strong>current</strong> block to match, in order that it is <strong>always</strong> followed by a <strong>NON-word</strong> character, in the <strong>44</strong> characters <strong>limit</strong> !</p>
<p dir="auto">The searched regex is, simply : <strong><code>(?-s).{16,44}(?=\W)</code></strong>. You probably think : what the <strong>16</strong> number is for ?</p>
<p dir="auto">Well, from the link below, it happens that the <strong>longest non-coined</strong> and <strong>non-technical</strong> English word is the word <strong><code>antidisestablishmentarianism</code></strong>, which is <strong>28</strong> characters long !! ( and <strong>16</strong> is just equal to <strong>44 - 28</strong> )</p>
<p dir="auto"><a href="https://en.wikipedia.org/wiki/Longest_word_in_English" rel="nofollow ugc">https://en.wikipedia.org/wiki/Longest_word_in_English</a></p>
<p dir="auto">So, if we consider the simple text, below, with that <strong>long</strong> word :</p>
<pre><code class="language-c">1234567890123456 antidisestablishmentarianism 12345678901234
</code></pre>
<ul>
<li>
<p dir="auto">As the string <strong>1234567890123456 antidisestablishmentarianism</strong> is 45 characters long ( so more than the <strong>limit</strong> of <strong>44</strong> chars), the regex engine <strong>backtracks</strong>, searching, successively, from <strong>beginning</strong> of that text, for a string of <strong>43</strong> characters long, followed by a non-word character, then for a string of <strong>42</strong> characters long, followed by a <strong>non-word</strong> character … and so on, till it detects a <strong>first</strong> match : the string <strong>1234567890123456</strong>, of <strong>16</strong> characters long, which is followed with a <strong>space</strong> character</p>
</li>
<li>
<p dir="auto">A second search gets all the <strong>remaining</strong> characters, as the string <strong><code>‗</code>antidisestablishmentarianism 12345678901234</strong> is just <strong>44</strong> characters long</p>
</li>
<li>
<p dir="auto">Now, let’s suppose you add the digit <strong>5</strong> at the <strong>end</strong> of the <strong>example</strong> text, as below :</p>
</li>
</ul>
<pre><code class="language-c">1234567890123456 antidisestablishmentarianism 123456789012345
</code></pre>
<ul>
<li>This time, again, as the <strong>second</strong> resulting string would be <strong>45</strong> characters long, the regex engine <strong>backtracks</strong> and selects, only, the string <strong><code>‗</code>antidisestablishmentarianism</strong> ( <strong>29</strong> characters long ) as a <strong>second</strong> match. Finally, the <strong>third</strong> match is the <strong>16</strong> characters long string <strong><code>‗</code>123456789012345</strong> !</li>
</ul>
<hr />
<p dir="auto">Applying my <strong>S/R</strong>, to your <strong>two</strong> examples, we obtain :</p>
<pre><code class="language-c"># Original text 1

As your advisor I am qualified to assist you in all matters related to rule civilization. If you don’t require my services dismiss me to attend to other matters.

# Final text 1

As your advisor I am qualified to assist you        44
‗in all matters related to rule civilization        44
. If you don’t require my services dismiss          42
‗me to attend to other matters.                     31

# Original text 2

Greetings My Liege! As your personal advisor, I am qualified to assist you in all matters related to ruling our civilization. I am at your service.

# Final text 2

Greetings My Liege! As your personal advisor        44
, I am qualified to assist you in all               37
‗matters related to ruling our civilization.        44
‗I am at your service.                              22
</code></pre>
<p dir="auto">What do you think about this kind of <strong>slicing</strong> ? I do hope it could be OK for you :-))</p>
<hr />
<p dir="auto">So, to sump up :</p>
<ul>
<li>
<p dir="auto">First, go to <strong>Settings &gt; Preferences… &gt; Editing &gt; Vertical Edge Settings</strong></p>
</li>
<li>
<p dir="auto">Check the <strong>Show vertical edge</strong> and the <strong>Line mode</strong> options</p>
</li>
<li>
<p dir="auto">Type <strong>44</strong> in the <strong>Number of columns</strong> dialog and valid by <strong>Enter</strong></p>
</li>
<li>
<p dir="auto">Hit the <strong>close</strong> button, to close the <strong>Preferences</strong> dialog</p>
</li>
</ul>
<p dir="auto">=&gt; A <strong>blue</strong> line, located after the <strong>44th</strong> character, should appear ! ( BTW, I also supposed that your <strong>current</strong> font is a <strong>monospaced</strong> font, as, for instance, the <strong>Courrier New</strong> or the <strong>Consolas</strong> font ! )</p>
<ul>
<li>
<p dir="auto">Select, also, the menu option <strong>View &gt; Show Symbol &gt; Show White Space and TAB</strong></p>
</li>
<li>
<p dir="auto">Now, go back to the <strong>very beginning</strong> of your document ( <strong>Ctrl + Origin</strong> )</p>
</li>
<li>
<p dir="auto">Open the <strong>replace</strong> dialog ( <strong>Ctrl + H</strong> )</p>
</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?-s).{16,44}(?=\W)</code></strong></p>
<p dir="auto">REPLACE <strong><code>$0\r\n</code></strong></p>
<ul>
<li>Click on the <strong>Replace All</strong> button…  Et voilà !</li>
</ul>
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">The <strong><code>(?-s)</code></strong> part is a <strong>modifier</strong>, that forces the regex engine to consider the <strong>dot</strong> meta-character as matching a <strong>single standard</strong> character, only ( NOT the <strong><code>\r</code></strong> and the <strong><code>\n</code></strong> characters )</p>
</li>
<li>
<p dir="auto">Then the <strong><code>.{16,44}</code></strong> part tries to match the <strong>longest</strong> string, containing between <strong>16</strong> to <strong>44</strong> characters, included</p>
</li>
<li>
<p dir="auto">With the additional <strong>condition</strong> that the character, following that string, must be a <strong>NON-word</strong> character, due to the <strong>positive look-ahead</strong> syntax <strong><code>(?=\W)</code></strong></p>
</li>
<li>
<p dir="auto">In <strong>replacement</strong>, we, first, rewrite the <strong>entire searched</strong> string <strong><code>$0</code></strong>, followed by the string <strong><code>\r\n</code></strong>, which inserts the two <strong>Windows End of Line</strong> characters</p>
</li>
<li>
<p dir="auto">In case, you’re using <strong>Unix</strong> files, note that the <strong>replacement</strong> zone should be <strong><code>$0\n</code></strong>, only</p>
</li>
</ul>
<hr />
<p dir="auto">Finally, from the original <strong>paragraph 5</strong> of the <strong>license.txt</strong> file of N++ <strong>v7.3.3</strong>, below :</p>
<pre><code class="language-diff">5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
</code></pre>
<p dir="auto">We would obtain, after <strong>replacement</strong> :</p>
<pre><code class="language-diff">5. You are not required to accept this
‗License, since you have not signed it.
‗However, nothing else grants you permission
‗to modify or distribute the Program or its
‗derivative works. These actions are
‗prohibited by law if you do not accept this
‗License. Therefore, by modifying or
‗distributing the Program (or any work based
‗on the Program), you indicate your
‗acceptance of this License to do so, and
‗all its terms and conditions for copying,
‗distributing or modifying the Program or
‗works based on it.
</code></pre>
<p dir="auto">Just notice that the <strong>space</strong> character ( usual word separator ) is <strong>always</strong> moved, with that S/R, at <strong>beginning</strong> of the <strong>next</strong> line. You may prefer the <strong>other</strong> text arrangement, below, where the <strong>non-word</strong> character is simply the <strong>last</strong> character of each <strong>final</strong> line, using the regex <strong><code>.{16,43}\W</code></strong> :</p>
<pre><code class="language-diff">5. You are not required to accept this‗
License, since you have not signed it.‗
However, nothing else grants you permission‗
to modify or distribute the Program or its‗
derivative works. These actions are 
prohibited by law if you do not accept this‗
License. Therefore, by modifying or‗
distributing the Program (or any work based‗
on the Program), you indicate your‗
acceptance of this License to do so, and‗
all its terms and conditions for copying,‗
distributing or modifying the Program or‗
works based on it.
</code></pre>
<p dir="auto">See you later,</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
</blockquote>
<p dir="auto">That is how genius answers! Wow I’m impressed!! I didn’t realize that my purpose can be achieved!</p>
<p dir="auto">Still haven’t tested it, but it is enough to know what is the possibilities that your help would gets.</p>
<p dir="auto">Thanks very much, I will back with results.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23770</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23770</guid><dc:creator><![CDATA[hu ma]]></dc:creator><pubDate>Sat, 22 Apr 2017 22:31:18 GMT</pubDate></item><item><title><![CDATA[Reply to Insert a string after each number of words with conditions on Sat, 19 Nov 2022 03:45:47 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="/user/abuali-huma" aria-label="Profile: abuali-huma">@<bdi>abuali-huma</bdi></a>,</p>
<p dir="auto">post <strong>UPDATED</strong>, on <strong>04/172017</strong>, with the help of <a class="plugin-mentions-user plugin-mentions-a" href="/user/alan-kilborn" aria-label="Profile: Alan-Kilborn">@<bdi>Alan-Kilborn</bdi></a>. See :</p>
<p dir="auto"><a href="https://notepad-plus-plus.org/community/topic/13686/insert-a-string-after-each-number-of-words-with-conditions/8" rel="nofollow ugc">https://notepad-plus-plus.org/community/topic/13686/insert-a-string-after-each-number-of-words-with-conditions/8</a></p>
<p dir="auto">I think that you could obtain what you want, by using a S/R, with <strong>regular</strong> expressions, but not exactly with the <strong>same template</strong> that you proposed !</p>
<p dir="auto">Before giving you the simple <strong>search</strong> and <strong>replacement</strong> regexes, needed, and the explanation of the <strong>slight</strong> differences with your seeked results, that produces this <strong>S/R</strong>, I would like to recapitulate your <strong>two</strong> examples, as I did <strong>not</strong> find, exactly, the same results as you ;-))</p>
<p dir="auto"><strong>IMPORTANT</strong> :</p>
<p dir="auto">Throughout all this post, I simply replaced the <strong>leading</strong> and <strong>trailing</strong> spaces, of the <strong>final</strong> lines of text, by the <strong>Double Low Line</strong> Unicode character <strong><code>‗</code></strong> ( <strong><code>\x{2017}</code></strong> ). It’s more readable and rigorous, isn’t it ?</p>
<pre><code class="language-c"># Original text 1

As your advisor I am qualified to assist you in all matters related to rule civilization. If you don’t require my services dismiss me to attend to other matters.

# Correct Result 1 :

As your advisor I am qualified to assist you‗       45
in all matters related to rule civilization.        44
‗If you don’t require my services dismiss me        44
‗to attend to other matters.                        28

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# Original text 2

Greetings My Liege! As your personal advisor, I am qualified to assist you in all matters related to ruling our civilization. I am at your service.

# Unwanted Result 2 :

Greetings My Liege! As your personal advisor        44
, I am qualified to assist you in all matter        44
s related to ruling our civilization. I am a        44
t your service.                                     15

# Wanted Result 2 :

Greetings My Liege! As your personal‗               37
advisor, I am qualified to assist you in all        44
‗matters related to ruling our civilization.        44
‗I am at your service.                              22
</code></pre>
<p dir="auto">To my mind, compared to your post, I think that :</p>
<ul>
<li>
<p dir="auto">The <strong>first</strong> block of the <strong>Correct Result 1</strong> is <strong>45</strong> characters long ( not 44 ), due to the <strong>final space</strong> character</p>
</li>
<li>
<p dir="auto">The <strong>first</strong> block of the <strong>Wanted Result 2</strong> is <strong>37</strong> character long ( not 36 ), for the same reason !</p>
</li>
</ul>
<hr />
<p dir="auto">Now, I think that the behaviour, about the <strong>slicing</strong> that you seek for, <strong>cannot</strong> be easily achieved with <strong>regular</strong> expressions, as the insertion of the <strong>End of Line</strong> character(s), inside text, would depend on the character <strong>right after</strong> the end of the <strong>next</strong> block of <strong>44</strong> characters ! I did try to find a suitable regex, <strong>without</strong> success, unfortunately :-((</p>
<p dir="auto">But I’ve got an <strong>other</strong> solution, which works out the <strong>current</strong> block to match, in order that it is <strong>always</strong> followed by a <strong>NON-word</strong> character, in the <strong>44</strong> characters <strong>limit</strong> !</p>
<p dir="auto">The searched regex is, simply : <strong><code>(?-s).{1,44}(?=\W)</code></strong>.</p>
<p dir="auto">Applying this <strong>S/R</strong>, to your <strong>two</strong> examples, we obtain :</p>
<pre><code class="language-c"># Original text 1

As your advisor I am qualified to assist you in all matters related to rule civilization. If you don’t require my services dismiss me to attend to other matters.

# Final text 1

As your advisor I am qualified to assist you        44
‗in all matters related to rule civilization        44
. If you don’t require my services dismiss          42
‗me to attend to other matters.                     31

# Original text 2

Greetings My Liege! As your personal advisor, I am qualified to assist you in all matters related to ruling our civilization. I am at your service.

# Final text 2

Greetings My Liege! As your personal advisor        44
, I am qualified to assist you in all               37
‗matters related to ruling our civilization.        44
‗I am at your service.                              22
</code></pre>
<p dir="auto">What do you think about this kind of <strong>slicing</strong> ? I do hope it could be OK for you :-))</p>
<hr />
<p dir="auto">So, to sump up :</p>
<ul>
<li>
<p dir="auto">First, go to <strong>Settings &gt; Preferences… &gt; Editing &gt; Vertical Edge Settings</strong></p>
</li>
<li>
<p dir="auto">Check the <strong>Show vertical edge</strong> and the <strong>Line mode</strong> options</p>
</li>
<li>
<p dir="auto">Type <strong>44</strong> in the <strong>Number of columns</strong> dialog and valid by <strong>Enter</strong></p>
</li>
<li>
<p dir="auto">Hit the <strong>close</strong> button, to close the <strong>Preferences</strong> dialog</p>
</li>
</ul>
<p dir="auto">=&gt; A <strong>blue</strong> line, located after the <strong>44th</strong> character, should appear ! ( BTW, I also supposed that your <strong>current</strong> font is a <strong>monospaced</strong> font, as, for instance, the <strong>Courrier New</strong> or the <strong>Consolas</strong> font ! )</p>
<ul>
<li>
<p dir="auto">Select, also, the menu option <strong>View &gt; Show Symbol &gt; Show White Space and TAB</strong></p>
</li>
<li>
<p dir="auto">Now, go back to the <strong>very beginning</strong> of your document ( <strong>Ctrl + Origin</strong> )</p>
</li>
<li>
<p dir="auto">Open the <strong>replace</strong> dialog ( <strong>Ctrl + H</strong> )</p>
</li>
</ul>
<p dir="auto">SEARCH <strong><code>(?-s).{1,44}(?=\W)</code></strong></p>
<p dir="auto">REPLACE <strong><code>$0\r\n</code></strong></p>
<ul>
<li>
<p dir="auto">Select the <strong>Regular expression</strong> search mode</p>
</li>
<li>
<p dir="auto">Click on the <strong>Replace All</strong> button…  Et voilà !</p>
</li>
</ul>
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">The <strong><code>(?-s)</code></strong> part is a <strong>modifier</strong>, that forces the regex engine to consider the <strong>dot</strong> meta-character as matching a <strong>single standard</strong> character, only ( NOT the <strong><code>\r</code></strong> and the <strong><code>\n</code></strong> characters )</p>
</li>
<li>
<p dir="auto">Then the <strong><code>.{1,44}</code></strong> part tries to match the <strong>longest</strong> string, containing between <strong>1</strong> to <strong>44</strong> characters, included</p>
</li>
<li>
<p dir="auto">With the additional <strong>condition</strong> that the character, following that string, must be a <strong>NON-word</strong> character, due to the <strong>positive look-ahead</strong> syntax <strong><code>(?=\W)</code></strong></p>
</li>
<li>
<p dir="auto">In <strong>replacement</strong>, we, first, rewrite the <strong>entire searched</strong> string <strong><code>$0</code></strong>, followed by the string <strong><code>\r\n</code></strong>, which inserts the two <strong>Windows End of Line</strong> characters</p>
</li>
<li>
<p dir="auto">In case, you’re using <strong>Unix</strong> files, note that the <strong>replacement</strong> zone should be <strong><code>$0\n</code></strong>, only</p>
</li>
</ul>
<hr />
<p dir="auto">Finally, from the original <strong>paragraph 5</strong> of the <strong>license.txt</strong> file of N++ <strong>v7.3.3</strong>, below :</p>
<pre><code class="language-diff">5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.
</code></pre>
<p dir="auto">We would obtain, after <strong>replacement</strong> :</p>
<pre><code class="language-diff">5. You are not required to accept this
‗License, since you have not signed it.
‗However, nothing else grants you permission
‗to modify or distribute the Program or its
‗derivative works. These actions are
‗prohibited by law if you do not accept this
‗License. Therefore, by modifying or
‗distributing the Program (or any work based
‗on the Program), you indicate your
‗acceptance of this License to do so, and
‗all its terms and conditions for copying,
‗distributing or modifying the Program or
‗works based on it.
</code></pre>
<p dir="auto">Just notice that the <strong>space</strong> character ( usual word separator ) is <strong>always</strong> moved, with that S/R, at <strong>beginning</strong> of the <strong>next</strong> line. You may prefer the <strong>other</strong> text arrangement, below, where the <strong>non-word</strong> character is simply the <strong>last</strong> character of each <strong>final</strong> line, using the S/R</p>
<p dir="auto">SEARCH <strong><code>(?-s).{1,43}\W</code></strong></p>
<p dir="auto">REPLACE <strong><code>$0\r\n</code></strong></p>
<pre><code class="language-diff">5. You are not required to accept this‗
License, since you have not signed it.‗
However, nothing else grants you permission‗
to modify or distribute the Program or its‗
derivative works. These actions are‗
prohibited by law if you do not accept this‗
License. Therefore, by modifying or‗
distributing the Program (or any work based‗
on the Program), you indicate your‗
acceptance of this License to do so, and‗
all its terms and conditions for copying,‗
distributing or modifying the Program or‗
works based on it.
</code></pre>
<p dir="auto">See you later,</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/23760</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/23760</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sat, 19 Nov 2022 03:45:47 GMT</pubDate></item></channel></rss>