<?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[PythonScript wrap around find&#x2F;replace]]></title><description><![CDATA[<p dir="auto">Is there some way to enable/disable <code>Wrap around</code> for find/replace via PythonScript? I would have expected that to be one of the possible <a href="https://docs.python.org/3/library/re.html#flags" rel="nofollow ugc">re module flags</a> available, but doesn’t look like it to me.</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/24607/pythonscript-wrap-around-find-replace</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 03:16:22 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/24607.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 21 Jun 2023 15:50:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to PythonScript wrap around find&#x2F;replace on Wed, 21 Jun 2023 17:46:21 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> , <a class="plugin-mentions-user plugin-mentions-a" href="/user/peterjones" aria-label="Profile: PeterJones">@<bdi>PeterJones</bdi></a> :</p>
<p dir="auto">Thanks for weighing in. What I’m trying to do is a somewhat complicated regex find/replace on a file roughly represented as such:</p>
<pre><code>[1st line containing data to be used in replacement elsewhere]
[…]
[2nd line containing data to be used in replacement elsewhere]
[…]
[3rd line containing data to be used in replacement elsewhere]
[…]
[1st line where replacement will take place]
[…]
[2nd line where replacement will take place]
[…]
[3rd line where replacement will take place]
[…]
</code></pre>
<p dir="auto">Each instance of <code>[…]</code> is one or more lines of other data.</p>
<p dir="auto">Starting at the beginning of the file, my FIND pattern will match from <code>[1st line containing data to be used in replacement elsewhere]</code> all the way through <code>[1st line where replacement will take place]</code>, then insert data retrieved from the former into the latter, and also deleting all lines from start of file up to but not including <code>[2nd line containing data to be used in replacement elsewhere]</code> in the same process. I was hoping it would be simple to have it go on finding/replacing for all the remaining corresponding line pairs if I could make it use <code>Wrap around</code> and <code>Replace All</code>— though perhaps it wouldn’t, since some of the data within the target match areas will have changed between quasi-iterations — but guess I’ll concede defeat and make a loop. Thanks again!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87298</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87298</guid><dc:creator><![CDATA[M Andre Z Eckenrode]]></dc:creator><pubDate>Wed, 21 Jun 2023 17:46:21 GMT</pubDate></item><item><title><![CDATA[Reply to PythonScript wrap around find&#x2F;replace on Wed, 21 Jun 2023 16:47:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a> ,</p>
<p dir="auto">There are two ways of looking at “wrap around”</p>
<ol>
<li>If you really mean, “I want to search the whole document, regardless of where my caret is right now.”  That can easily be implemented using the startPosition=0 argument.  (I believe that’s what effectively happens when you do a regular expression replacement in the N++ Replace dialog using Replace All)</li>
<li>If you really mean, “I want to search the whole document, starting where I am right now and going until the end.”  For that in PythonScript, if p is the current caret location, then do it with two calls to the editor.rereplace() or similar function: the first with startPosition=p and endPosition as the length of the file (or without it supplied, that’s what it will default to); and then a second with startPosition=0 and endPosition=p (… which is what Alan posted just as I was typing the last clause)</li>
</ol>
]]></description><link>https://community.notepad-plus-plus.org/post/87297</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87297</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 21 Jun 2023 16:47:13 GMT</pubDate></item><item><title><![CDATA[Reply to PythonScript wrap around find&#x2F;replace on Wed, 21 Jun 2023 16:47:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/m-andre-z-eckenrode" aria-label="Profile: M-Andre-Z-Eckenrode">@<bdi>M-Andre-Z-Eckenrode</bdi></a></p>
<p dir="auto">No, if you want it to “wrap around”, you’d have to do two calls to editor.research().  The first one should search caret position to end-of-file position, then the second one should search position 0 to the original caret position.</p>
<p dir="auto">Note that in Notepad++ searches with “wrap around” enabled, it also does this; there is no native support in Scintilla for it.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/87296</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/87296</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Wed, 21 Jun 2023 16:47:24 GMT</pubDate></item></channel></rss>