<?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[re-numbering phrase+number in the middle of sentence]]></title><description><![CDATA[<p dir="auto">hi, this is part of a file which i need to incremental by 1 inside the phrase “int[] arr1”,<br />
how can i do it?</p>
<pre><code>    int[] arr1 = {6, 7, 8}; 
    listArr.add(arr1); 
    int[] arr1 = {4, 5, 6}; 
    listArr.add(arr2); 
    int[] arr1 = {2, 3, 4};
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/topic/21725/re-numbering-phrase-number-in-the-middle-of-sentence</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 01:33:15 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/21725.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 24 Aug 2021 15:32:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to re-numbering phrase+number in the middle of sentence on Thu, 26 Aug 2021 18:49:59 GMT]]></title><description><![CDATA[<p dir="auto">finally got it!<br />
the problem was unnecessary space<br />
thank u all !!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69310</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69310</guid><dc:creator><![CDATA[B MR]]></dc:creator><pubDate>Thu, 26 Aug 2021 18:49:59 GMT</pubDate></item><item><title><![CDATA[Reply to re-numbering phrase+number in the middle of sentence on Thu, 26 Aug 2021 13:19:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/22947">@B-MR</a> ,</p>
<p dir="auto">and here’s a video of it working for me:<br />
<img src="https://camo.nodebb.org/af1d11c24710fd5cc8baae29f830340fd03a762a?url=https%3A%2F%2Fi.imgur.com%2FwO0ttmV.gif" alt="" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.notepad-plus-plus.org/post/69299</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69299</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 26 Aug 2021 13:19:32 GMT</pubDate></item><item><title><![CDATA[Reply to re-numbering phrase+number in the middle of sentence on Thu, 26 Aug 2021 13:12:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/22947">@B-MR</a> ,</p>
<blockquote>
<p dir="auto"><img src="/assets/uploads/files/1629983194395-fecf8835-adaf-40b6-9049-675a30410745-image.png" alt="fecf8835-adaf-40b6-9049-675a30410745-image.png" class=" img-fluid img-markdown" /></p>
</blockquote>
<p dir="auto">If that’s literally and exactly what’s inside your Notepad++ window when editing the script, it is definitely not going to work, as that’s <em>not</em> valid python code.</p>
<p dir="auto">As <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> said, the forum got rid of two backslashes, as he showed in a screenshot earlier.  So you need to make sure you include those backslashes</p>
<p dir="auto"><img src="/assets/uploads/files/1629983457759-e442cf57-f06d-4b61-96dd-277b73c04eb6-image.png" alt="e442cf57-f06d-4b61-96dd-277b73c04eb6-image.png" class=" img-fluid img-markdown" /><br />
(please note: mine starts at line 37 because I also have all the other lines from the black box in the saved <code>*.py</code> file – those are comments, and can be saved as part of the script for future reference)</p>
<p dir="auto">Let me try to re-embed the code in the forum for easy copy/paste:</p>
<pre><code># encoding=utf-8
"""this uses the "add_1" style search and replace in Notepad++

INSTRUCTIONS:
1. Install PythonScript
   * Plugins &gt; Plugins Admin
   * Click ☑ PythonScript checkbox until checked
   * click INSTALL
   * restart Notepad++ as necessary
2. Create new PythonScript script
   * Plugins &gt; PythonScript &gt; New Script
   * Give it a reasonable name, like add_1.py
   * Paste in the code from this black box
   * Save
3. Switch to the document where you want to search/replace
4. Plugins &gt; PythonScript &gt; Scripts &gt; add_1

To assign a keyboard shortcut:
1. Plugins &gt; PythonScript &gt; Configuration
2. In the User Scripts, click on add_1.py
3. Click the left ADD button (above Menu Items)
    * This adds "add_1" to the main Plugins &gt; PythonScript menu, rather
      than requiring you to dig down into the Scripts submenu
4. Exit Notepad++ and restart
    * This is required for ShortcutMapper to be able to see the new entry
      in the PythonScript menu
5. Settings &gt; ShortcutMapper &gt; Plugin Commands
6. Filter by add_1
7. Click on add_1, then click the MODIFY button and
    set the keyboard shortcut in the dialog

You can change the replacement values, or the number of replacements,
then save, and it will still run.

PythonScript has documentation in its Context-Sensitive Help
"""
from Npp import *

counter = 1

def add_1(m):
    global counter
    repl = str(counter)
    counter = counter + 1
    return repl

def disp_1(m):
    console.write("found {}\n".format(m.group()))

editor.rereplace(r'(?&lt;=int\\[\\] arr)\d+', add_1)
</code></pre>
<p dir="auto">After pasting that and saving that, as described in the original instructions, what <em>exactly</em> were the steps you took?  If it still doesn’t work with the correct final line in the code, could you go to <strong>Plugins &gt; Python Script &gt; Show Console</strong> and see if there are any error messages listed in the PythonScript console?  and if there are, screenshot them and paste the image in your reply?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69296</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69296</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 26 Aug 2021 13:12:27 GMT</pubDate></item><item><title><![CDATA[Reply to re-numbering phrase+number in the middle of sentence on Thu, 26 Aug 2021 11:30:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a></p>
<p dir="auto">Just a note to say it worked perfectly when I tried it, of course with the slight tweak I made to it because of the forum posting error (as detailed above).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69290</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69290</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 26 Aug 2021 11:30:55 GMT</pubDate></item><item><title><![CDATA[Reply to re-numbering phrase+number in the middle of sentence on Thu, 26 Aug 2021 11:19:29 GMT]]></title><description><![CDATA[<p dir="auto">tried it<br />
step by step<br />
and it did nothing</p>
<p dir="auto">this is what copied:<br />
from Npp import *</p>
<p dir="auto">counter = 1</p>
<p dir="auto">def add_1(m):<br />
global counter<br />
repl = str(counter)<br />
counter = counter + 1<br />
return repl</p>
<p dir="auto">def disp_1(m):<br />
console.write(“found {}\n”.format(m.group()))</p>
<p dir="auto">editor.rereplace(r’(?&lt;=int[] arr) \d+', add_1)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69288</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69288</guid><dc:creator><![CDATA[B MR]]></dc:creator><pubDate>Thu, 26 Aug 2021 11:19:29 GMT</pubDate></item><item><title><![CDATA[Reply to re-numbering phrase+number in the middle of sentence on Wed, 25 Aug 2021 12:40:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a> said in <a href="/post/69218">re-numbering phrase+number in the middle of sentence</a>:</p>
<blockquote>
<p dir="auto">rere</p>
</blockquote>
<p dir="auto">sorry, i did not, i don’t have any knowledge of code,<br />
but maybe i’ll try later</p>
<p dir="auto">thank you alan</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69252</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69252</guid><dc:creator><![CDATA[B MR]]></dc:creator><pubDate>Wed, 25 Aug 2021 12:40:05 GMT</pubDate></item><item><title><![CDATA[Reply to re-numbering phrase+number in the middle of sentence on Wed, 25 Aug 2021 12:32:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a></p>
<p dir="auto">I think the forum again consumed the backslash in front of <code>[</code> and <code>]</code> in your code.  I think this should be the correct line in the code:</p>
<p dir="auto"><img src="/assets/uploads/files/1629894686216-d7504737-67ef-45f0-8e25-79271fe780c6-image.png" alt="d7504737-67ef-45f0-8e25-79271fe780c6-image.png" class=" img-fluid img-markdown" /></p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/22947">@B-MR</a> said:</p>
<blockquote>
<p dir="auto">i do not know what and how to change the code to my needs</p>
</blockquote>
<p dir="auto">Aside from the forum posting error I mentioned, Peter gave you everything you’d need for what you asked for – did you even try to follow the step-by-step-spoon-feed-me instructions?</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69251</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69251</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 25 Aug 2021 12:32:52 GMT</pubDate></item><item><title><![CDATA[Reply to re-numbering phrase+number in the middle of sentence on Wed, 25 Aug 2021 12:14:02 GMT]]></title><description><![CDATA[<p dir="auto">i do not know what and how to change the code to my needs<br />
thank you any way</p>
]]></description><link>https://community.notepad-plus-plus.org/post/69249</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69249</guid><dc:creator><![CDATA[B MR]]></dc:creator><pubDate>Wed, 25 Aug 2021 12:14:02 GMT</pubDate></item><item><title><![CDATA[Reply to re-numbering phrase+number in the middle of sentence on Tue, 24 Aug 2021 15:47:05 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/22947">@B-MR</a> ,</p>
<p dir="auto">With just Notepad++ and nothing else, you cannot.  If you are willing to use a plugin, it’s easy.</p>
<p dir="auto">You can install the PythonScript plugin, and use the example <code>add_1</code> that’s in the documentation; you’d have to change the search regular expression in the script to suit your needs</p>
<p dir="auto">You can search this forum for examples of <a href="https://community.notepad-plus-plus.org/search?term=add_1&amp;in=posts&amp;matchWords=all&amp;sortBy=timestamp&amp;sortDirection=desc&amp;showAs=posts"><code>add_1</code> and related pythonscript replacements</a></p>
<p dir="auto">Based on my interpretation of what you said,</p>
<pre><code># encoding=utf-8
"""this uses the "add_1" style search and replace in Notepad++

INSTRUCTIONS:
1. Install PythonScript
   * Plugins &gt; Plugins Admin
   * Click ☑ PythonScript checkbox until checked
   * click INSTALL
   * restart Notepad++ as necessary
2. Create new PythonScript script
   * Plugins &gt; PythonScript &gt; New Script
   * Give it a reasonable name, like add_1.py
   * Paste in the code from this black box
   * Save
3. Switch to the document where you want to search/replace
4. Plugins &gt; PythonScript &gt; Scripts &gt; add_1

To assign a keyboard shortcut:
1. Plugins &gt; PythonScript &gt; Configuration
2. In the User Scripts, click on add_1.py
3. Click the left ADD button (above Menu Items)
    * This adds "add_1" to the main Plugins &gt; PythonScript menu, rather
      than requiring you to dig down into the Scripts submenu
4. Exit Notepad++ and restart
    * This is required for ShortcutMapper to be able to see the new entry
      in the PythonScript menu
5. Settings &gt; ShortcutMapper &gt; Plugin Commands
6. Filter by add_1
7. Click on add_1, then click the MODIFY button and
    set the keyboard shortcut in the dialog

You can change the replacement values, or the number of replacements,
then save, and it will still run.

PythonScript has documentation in its Context-Sensitive Help
"""
from Npp import *

counter = 1

def add_1(m):
    global counter
    repl = str(counter)
    counter = counter + 1
    return repl

def disp_1(m):
    console.write("found {}\n".format(m.group()))

editor.rereplace(r'(?&lt;=int\[\] arr)\d+', add_1)
</code></pre>
<p dir="auto">which turned your example data into</p>
<pre><code>    int[] arr1 = {6, 7, 8}; 
    listArr.add(arr1); 
    int[] arr2 = {4, 5, 6}; 
    listArr.add(arr2); 
    int[] arr3 = {2, 3, 4};
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/69218</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/69218</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 24 Aug 2021 15:47:05 GMT</pubDate></item></channel></rss>